On Jul 20, 2010, at 9:26 AM, Jim Hargreaves wrote:

Dear List,

After much searching with no success, I would like to ask how I can convert a unix/POSIX time (seconds since Jan 01, 1970) into a string like "01/01/1970 00:00"

This is probably easily done with a system(date...) but it would be great if I could do it in R.

By default DateTime objects are printed similarly to your specification:

> Sys.time()
[1] "2010-07-20 09:34:36 EDT"

> as.numeric( Sys.time() ) # the internal representation
[1] 1279632906

The default format for the default print function is YYYY-MM-DD HH:MM TZ. You can find the format codes with:

?strptime

> print(Sys.time(), format="%m/%d/%Y %H:%M") # your request is ambiguous w.r.t month and day order
[1] "07/20/2010 09:39 EDT"


--

David Winsemius, MD
West Hartford, CT

______________________________________________
R-help@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.

Reply via email to