title: PostgreSQL SQLalchemy and timestamp with time zone, why is incognito different from normal?
body: <p>I am using flask sqlalchemy and postgreSQL and I have issues with the displayed datetimes, while investigating this issue I found an other weird thing:</p>
  
  <p>Creating a DB entry in incognito mode (chrome browser tab) gives a different/wrong time.
  EDIT: It has nothing to do with incognito mode, both cases happen in normal mode aswell. I have not figured out yet why.</p>
  
  <p>This is the code:</p>
  
  <p>I changed the default time zone of my database:</p>
  
  <pre><code>ALTER DATABASE postgres SET timezone TO 'Europe/Berlin';
  </code></pre>
  
  <p>the model:</p>
  
  <pre><code>class User(UserMixin, Base):
      __tablename__ = 'users'
      date_added = Column(DateTime(timezone=True), nullable=False)
  </code></pre>
  
  <p>The method I use to add datetime to DB:</p>
  
  <pre><code>date_added=datetime.today()
  </code></pre>
  
  <p>How it looks in the DB (my localtime at this time was 13:53:46):</p>
  
  <p>Creating entry not in incognito</p>
  
  <pre><code>timestamp with time zone
  2019-02-01 13:53:46.73817+01
  </code></pre>
  
  <p>Creating entry in incognito</p>
  
  <pre><code>timestamp with time zone
  2019-02-01 12:53:46.73817+01
  </code></pre>
  
  <p>This really makes me worry. It is simply wrong. Even if I would convert the datetime objects to localtime. Both entries have been done at the same time, but show different results, how is this possible?</p>
  
  <p>Also when viewing these dates in HTML, postgreSQL does not apply the offset, so the first date looks correct, but the second is wrong.</p>
  
  <p>Initially I just wanted to find a way to store ALL datetime objects in Europe/Berlin and return them in Europe/Berlin time, so I dont have to convert UTC to Europe/Berlin, but now I think something went horribly wrong.</p>
  
  <p>I also have double checked my code everywhere, I am not using other methods to manipulate datetime objects.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I am saving a datetime everytime a user logs in. Currently I tried this on not incognito. My localtime is <code>14:13:33</code> BUT it saved into the DB:
  <code>2019-02-01 13:13:33.804339+01</code>. How is this even possible? I know it cant be random, but right now it looks like its saving times randomly sometimes UTC with offset and sometimes Europe/Berlin with offset.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I double checked all tables in question with <code>SHOW timezone;</code> and they all correctly return <code>Europe/Berlin</code></p>