0

I am testing MATLAB to ensure that I am correctly applying its functionality. An example from the a data source includes:

  • The current time in UNIX epoch seconds is: 1160967053
  • The current time in New York is Sun Oct 15 22:50:53 EDT 2006

I am assuming that the above is correct and attempting to reproduce the result in MATLAB:

dt = datetime( 1160967053, 'ConvertFrom', 'posixtime' )

which returns:

 dt = 16-Oct-2006 02:50:53

This result is +4 hours: I was expecting +5 hours. New York time is UTC -5. There is discrepancy of 1 hour: daylight savings time?

When adding the timezone to the function, the result matches the reference example:

T = datetime(1160967053,'ConvertFrom','posixtime','TimeZone','America/New_York')

 T = 15-Oct-2006 22:50:53

Questions

  • If NYC is UTC -5, why is the difference 4 hours?
  • daylight saving time (yuck!) was fiddled with in the "Energy Policy Act of 2005" so something could miss by an hour if it does not take such random changes into account – thrig May 7 '18 at 21:25
1

Yes, the timestamp 1160967053 represents this date (on UTC):

$ date -ud @1160967053
Mon Oct 16 02:50:53 UTC 2006

And the correct time at New York is:

$ TZ="America/New_York" date -d @1160967053
Sun Oct 15 22:50:53 EDT 2006

Yes, 4 (four) hours behind.

The EDT tag clearly says: East Daylight Time.

The next change to "Standard" time for that year is:

$ zdump -c 2006,2007 -v /usr/share/zoneinfo/America/New_York
/usr/share/zoneinfo/America/New_York  Sun Apr  2 06:59:59 2006 UT = Sun Apr  2 01:59:59 2006 EST isdst=0 gmtoff=-18000
/usr/share/zoneinfo/America/New_York  Sun Apr  2 07:00:00 2006 UT = Sun Apr  2 03:00:00 2006 EDT isdst=1 gmtoff=-14400
/usr/share/zoneinfo/America/New_York  Sun Oct 29 05:59:59 2006 UT = Sun Oct 29 01:59:59 2006 EDT isdst=1 gmtoff=-14400
/usr/share/zoneinfo/America/New_York  Sun Oct 29 06:00:00 2006 UT = Sun Oct 29 01:00:00 2006 EST isdst=0 gmtoff=-18000

So, If we move 15 days forward, the time is:

$ TZ="America/New_York" date -d "Sun Oct 15 22:50:53 EDT 2006 + 15 days"
Mon Oct 30 21:50:53 EST 2006

That's EST: East Standard Time (or 5 hours behind UTC+0)

I don't see any problem.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.