|
I think your problem is higher up the stack. Try running this SQL create table tz_test (
comment varchar,
ts timestamp,
ts_tz timestamptz
); insert into tz_test (comment, ts, ts_tz) values
( 'in "local"', TIMESTAMP WITH TIME ZONE '2003-04-12 04:05:06 America/New_York', TIMESTAMP WITH TIME zone '2003-04-12 04:05:06 America/New_York'),
( 'flattened to UTC', (TIMESTAMP WITH TIME ZONE '2003-04-12 04:05:06 America/New_York') at time zone 'UTC', TIMESTAMP WITH TIME zone '2003-04-12 04:05:06 America/New_York'),
( 'in "local" no types', TIMESTAMP WITH TIME ZONE '2003-04-12 04:05:06 America/New_York', '2003-04-12 04:05:06 America/New_York'),
( 'flattened to UTC no types', (TIMESTAMP WITH TIME ZONE '2003-04-12 04:05:06 America/New_York') at time zone 'UTC', '2003-04-12 04:05:06 America/New_York'); select comment,
ts,
ts AT TIME ZONE 'UTC' as ts_utc,
ts_tz,
ts_tz AT TIME ZONE 'UTC' as ts_tz_utc,
case when ts < ts_tz then 'less' when ts>ts_tz then 'greater' else 'equal' end
from tz_test; |
When you look at your data, what is the time a user's watch said when the data was input? What time zone was the data input as?
Here's some queries:
I would expect that one row comes out as midnight, and the other row comes out as 4am. But they both come out as midnight. That's what I don't like.