I need to convert a bunch of dates in a MySQL database from Pacific time (America/Los_Angeles) to UTC. I found a great SO answer on how to do this.
During my tests and preparation, I'm finding that I'm getting the same time conversions when using any of the following time zone names:
- America/Los_Angeles
- US/Pacific
- PST8PDT
So my questions are the following:
- Are these all just aliases to the same thing? Or are there actual differences between them at some point in time?
- If I want to provide a list of timezones to users on a website, would it be better to give them selections from the
America
group of names, or theUS
group of names?
US/Pacific
is a "link" toAmerica/Los_Angeles
in the IANA database (see wikipedia). On Linux systems I've seen, the former is a hard linked file to the latter; on OS X it might be a copy. If you run a checksum (e.g. md5 or sha1) on the entries in/usr/share/zoneinfo/
the 2 should match.However,
PST8PDT
may be different - I haven't figured out exactly how. This bug report indicates that it doesn't track the history of daylight-saving changes, i.e. that it just retroactively applies the current DST rules to the past; but that doesn't seem to be the case in this ruby example. If it were retroactively applying the current rules, both would be-0700
:On this message there's a quote from the original database maintainer. The message author explains that the legacy zones including
PST8PDT
used to have obsolete info, but now are "less incorrect" whatever that means.To sum up, don't use
PST8PDT
, but it should be safe to use eitherUS/Pacific
orAmerica/Los_Angeles
.I ran into an issue with the parallel
US/Eastern
,Americas/New_York
, andEST5EDT
. Here is what I discovered.For dates after the Uniform Time Act of 1966 went into effect in 1967, these timezones are all identical. Also the US enforced standard DST rules during the World Wars, so they are all identical 1918-1919 and 1942-1945.
For any date before 1918, between 1920 and 1941 inclusive, and between 1946 and 1966 inclusive,
EST5EDT
will alway be identical toEST
.PST5PDT
will alway be identical to PST.Prior to 1967,
Americas/New_York
will provide the time as observed in New York City. So Daylight Savings Time will follow the rules in place by the NYC municipal or NY state government. Any date before 1883 Nov 18 12:03:58 will be in local mean time with an offset of -4:56:02 from UTC. ForAmericas/Los_Angeles
any time before 1883 Nov 18 12:07:02 will be local mean time with an offset of -7:52:58 fromUTC
. Between 1883 and 1967, Los Angeles follows the LA and California Daylight Savings rules.Odd things can happen if you have multiple systems where one assumes
PST8PDT
and the other assumesAmericas/Los_Angeles
. Data might look fine for anything recent. A birthdate for example, from the summer of 1966 might get moved an hour, then truncated so it appears to be on the prior day.And just for extra fun if you are dealing with old dates in Alaska, you need to remember that Alaska was Purchased from Russia. Dates before 1867 Oct 18 are on the other side of the international date line and use the Julian, not Gregorian Calendar. So Juneau, for example, went from 6 Oct 1867 (Julian) +15:02:19 to 18-Oct-1867 (Gregorian) -8:57:41.
US/Pacific and PST8PDT both belong to the "other" timezones, which come with this warning:
They should all refer to the same timezone, compare:
http://www.travelmath.com/time-zone/PST8PDT
http://www.travelmath.com/time-zone/US/Pacific
http://www.travelmath.com/time-zone/America/Los_Angeles
As such, you should use America/Los_Angeles, which incidentally should also be a pretty "natural" and easy thing to select for users.