Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The differences are covered at <a href="http://www.postgresql.org/docs/current/interactive/datatype-datetime.html" rel="noreferrer">the PostgreSQL documentation for date/time types</a>. Yes, the treatment of <code>TIME</code> or <code>TIMESTAMP</code> differs between one <code>WITH TIME ZONE</code> or <code>WITHOUT TIME ZONE</code>. It doesn't affect how the values are stored; it affects how they are interpreted.</p> <p>The effects of time zones on these data types is <a href="http://www.postgresql.org/docs/current/interactive/datatype-datetime.html#DATATYPE-TIMEZONES" rel="noreferrer">covered specifically</a> in the docs. The difference arises from what the system can reasonably know about the value:</p> <ul> <li><p>With a time zone as part of the value, the value can be rendered as a local time in the client.</p></li> <li><p>Without a time zone as part of the value, the obvious default time zone is UTC, so it is rendered for that time zone.</p></li> </ul> <p>The behaviour differs depending on at least three factors:</p> <ul> <li>The timezone setting in the client.</li> <li>The data type (i.e. <code>WITH TIME ZONE</code> or <code>WITHOUT TIME ZONE</code>) of the value.</li> <li>Whether the value is specified with a particular time zone.</li> </ul> <p>Here are examples covering the combinations of those factors:</p> <pre class="lang-sql prettyprint-override"><code>foo=&gt; SET TIMEZONE TO 'Japan'; SET foo=&gt; SELECT '2011-01-01 00:00:00'::TIMESTAMP; timestamp --------------------- 2011-01-01 00:00:00 (1 row) foo=&gt; SELECT '2011-01-01 00:00:00'::TIMESTAMP WITH TIME ZONE; timestamptz ------------------------ 2011-01-01 00:00:00+09 (1 row) foo=&gt; SELECT '2011-01-01 00:00:00+03'::TIMESTAMP; timestamp --------------------- 2011-01-01 00:00:00 (1 row) foo=&gt; SELECT '2011-01-01 00:00:00+03'::TIMESTAMP WITH TIME ZONE; timestamptz ------------------------ 2011-01-01 06:00:00+09 (1 row) foo=&gt; SET TIMEZONE TO 'Australia/Melbourne'; SET foo=&gt; SELECT '2011-01-01 00:00:00'::TIMESTAMP; timestamp --------------------- 2011-01-01 00:00:00 (1 row) foo=&gt; SELECT '2011-01-01 00:00:00'::TIMESTAMP WITH TIME ZONE; timestamptz ------------------------ 2011-01-01 00:00:00+11 (1 row) foo=&gt; SELECT '2011-01-01 00:00:00+03'::TIMESTAMP; timestamp --------------------- 2011-01-01 00:00:00 (1 row) foo=&gt; SELECT '2011-01-01 00:00:00+03'::TIMESTAMP WITH TIME ZONE; timestamptz ------------------------ 2011-01-01 08:00:00+11 (1 row) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload