[R] Problem with as.POSIXct on dates object

Remko Duursma remkoduursma at gmail.com
Mon Jul 20 05:30:09 CEST 2009


Dear R-helpers,


I have a problem converting an object made with the 'chron' function
to a POSIXct object:

# Make date based on DOY
dat <- chron(dates=232, origin.=c(month=1, day=1, year=2008))

dat
#[1] 08/20/08

# Converting to POSIXct uses current timezone (Sydney):
as.POSIXct(dat)
#[1] "2008-08-20 10:00:00 EST"

# Setting GMT timezone has no effect?
as.POSIXct(dat, tz="GMT")
#[1] "2008-08-20 10:00:00 EST"

# But to POSIXlt works fine:
as.POSIXlt(dat, tz="GMT")
#[1] "2008-08-20 GMT"

Is this behavior expected? If so, can you explain why?

thanks for your help,
Remko



-------------------------------------------------
Remko Duursma
Post-Doctoral Fellow

Centre for Plants and the Environment
University of Western Sydney
Hawkesbury Campus
Richmond NSW 2753

Dept of Biological Science
Macquarie University
North Ryde NSW 2109
Australia

Mobile: +61 (0)422 096908




More information about the R-help mailing list