Timezone names are not as simple as you would like. See http://en.wikipedia.org/wiki/Tz_database for background and http://en.wikipedia.org/wiki/List_of_tz_database_time_zones for a list of the names that are used. By far the best thing is to use the tz = 'country / city'
notation and to explicitly set the time zone of the local system.
So, here's a script that uses two different methods to encode the time zone:
Sys.setenv(TZ='GMT')
pst.abr <- as.POSIXct('2011-01-10 06:45:00', tz = 'PST')
est.abr <- as.POSIXct('2011-01-10 09:45:00', tz = 'EST')
pst.country.city <- as.POSIXct('2011-01-10 06:45:00', tz = 'America/Los_Angeles')
est.country.city <- as.POSIXct('2011-01-10 09:45:00', tz = 'America/New_York')
If we look at the POSIXct values that we would have like to have been PST, we see that they actually have two different values. Starting with the abbreviation (tz ='PST'
), you get this:
> pst.abr
[1] "2011-01-10 06:45:00 UTC"
> as.numeric(pst.abr)
[1] 1294641900
You see that the data we defined using tz='PST'
isn't actually in the PST timezone, but has inherited the system's timezone.
Compare this to the data we defined using the country\city:
> as.numeric(pst.country.city)
[1] 1294670700
> pst.country.city
[1] "2011-01-10 06:45:00 PST"
So, only the data that we explicitly encode with country/city information has the correct timezone information.