[R] Converting from "date strings" to internal POSIX format?

Gabor Grothendieck ggrothendieck at gmail.com
Thu Sep 3 19:24:29 CEST 2009


I assume you mean you wish to convert it from text to
to the numeric representation that POSIXct uses:

> options(digits = 20)
> as.numeric(as.POSIXct("2009-06-16 09:28:17.746"))
[1] 1245158897.746

If you just want convert it to POSIXct then omit the
as.numeric part.

On Thu, Sep 3, 2009 at 1:17 PM, Derek Eder<derek.eder at lungall.gu.se> wrote:
> I need to convert a date-style string:  "2009-06-16 09:28:17.746"
> To its POSIX representation: 1245137297746
>
>
> The function below converts my POSIX date to a string ... now I need to go backwards!
>
>
> render.t32 <- function(t32, tz = "CET")
>  {
>   timez <- ISOdatetime(1970,1,1,0,0,0, tz ="UTC")+t32/1000
>   return(format(timez,"%Y-%m-%d %H:%M:%OS3",tz="CET"))
>  }
>
>
>> render.t32(1245137297746)
> [1] "2009-06-16 09:28:17.746"
>
>
> Have not succeeded in my attempts to understand POSIX
> and I thank you for your attention.
>
> ~Derek
>
>
> Derek N. Eder
> Gothenburg University
> Vigilance and Neurocognition Laboratory
> Medicinaregatan 8B
> Box 421
> Gothenburg Sweden
> SE 405 30
>
> tlf (031) 342-8261
> mobil 0704 915 714
>
> "The most dangerous thing in the jungle is not the snakes, the spiders, the tigers, ...
> The most dangerous thing in the jungle is your mind!"
>
> ______________________________________________
> R-help at r-project.org 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.
>




More information about the R-help mailing list