[R] help with POSIX
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Fri Apr 22 21:11:22 CEST 2005
"Ghosh, Sandeep" <sghosh at lexgen.com> writes:
> For the r script below
>
> >datestr <- "01/01/2004"
> >as.POSIXct(as.Date(datestr, "%d/%m/%Y"))
> I get the following output
> "2003-12-31 18:00:00 Central Standard Time"
>
> Why is the date a day before. I guess its something to do with the
> time, but is there a way to get it to return 2004-01-01 instead?
Just move to Denmark:
> datestr <- "01/01/2004"
> as.POSIXct(as.Date(datestr, "%d/%m/%Y"))
[1] "2004-01-01 01:00:00 CET"
The convention is that Date objects are pegged to 0:00 GMT (not sure
what the rationale is -- ISOdate uses 12:00 GMT -- but Brian probably
thought about it). An easy workaround is to add 12 hours...
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help
mailing list