MySQL datetime fields and daylight savings time -- how do I reference the "extra" hour?

Posted by Aaron on Stack Overflow See other posts from Stack Overflow or by Aaron
Published on 2009-10-29T19:55:06Z Indexed on 2010/03/29 22:23 UTC
Read the original article Hit count: 117

Filed under:
|
|
|
|

I'm using the America/New York timezone. In the Fall we "fall back" an hour -- effectively "gaining" one hour at 2am. At the transition point the following happens:

it's 01:59:00 -04:00
then 1 minute later it becomes:
01:00:00 -05:00

So if you simply say "1:30am" it's ambiguous as to whether or not you're referring to the first time 1:30 rolls around or the second. I'm trying to save scheduling data to a MySQL database and can't determine how to save the times properly.

Here's the problem:
"2009-11-01 00:30:00" is stored internally as 2009-11-01 00:30:00 -04:00
"2009-11-01 01:30:00" is stored internally as 2009-11-01 01:30:00 -05:00

This is fine and fairly expected. But how do I save anything to 01:30:00 -04:00? The documentation does not show any support for specifying the offset and, accordingly, when I've tried specifying the offset it's been duly ignored.

The only solutions I've thought of involve setting the server to a timezone that doesn't use daylight savings time and doing the necessary transformations in my scripts (I'm using PHP for this). But that doesn't seem like it should be necessary.

Many thanks for any suggestions.

© Stack Overflow or respective owner

Related posts about mysql

Related posts about timestamp