Re: [R] Datetime

From: Peter Dalgaard <p.dalgaard_at_biostat.ku.dk>
Date: Wed 30 Aug 2006 - 23:02:45 EST

"COMTE Guillaume" <g.comte@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@biostat.ku.dk)                  FAX: (+45) 35327907

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Wed Aug 30 23:09:20 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 31 Aug 2006 - 00:23:43 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.