[R] Datetime
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Wed Aug 30 15:02:45 CEST 2006
"COMTE Guillaume" <g.comte at alliance-ir.net> writes:
> Hi all,
>
> I'm getting confused by date handling.
>
>
>
> I wish to read a date from a file wich is a number of seconds since 1970
> (POSIXct).
>
> Then i wish to convert this date to a human readable form (POSIXlt)
>
>
>
> By example :
>
>
>
> ctDate<-1132963200 #"Wed Aug 30 14:24:37 2006"
>
> is(ctDate)
>
> [1] "numeric" "vector"
>
>
>
> ctDate isn't a numeric vector, it is a POSIXct... none of the clues
> inside the docs has given me the answer, i can't cast it, i can't
> converti t to POSIXlt because it is wrong class (as.POSIX** don't want
> to work...)
>
>
>
> What is the trick ??
It *is* a numeric vector. You need to add it to the epoch time or do
an explicit conversion
> ISOdatetime(1970,1,1,1,0,0)+ctDate # epoch is 01:00 in CET
[1] "2005-11-26 01:00:00 CET"
> structure(ctDate,class="POSIXct")
[1] "2005-11-26 01:00:00 CET"
(Your date seems out of whack by some 24 million seconds...)
--
O__ ---- Peter Dalgaard Øster Farimagsgade 5, Entr.B
c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help
mailing list