[R] time conversion from second to Y M D H M S format

Berend Hasselman bhh at xs4all.nl
Thu Feb 2 21:23:13 CET 2012


On 02-02-2012, at 21:10, Berend Hasselman wrote:

> 
> On 02-02-2012, at 19:23, R. Michael Weylandt wrote:
> 
>> It works for me as well so there's something funny on your end: please
>> run the following *verbatim* (in a vanilla R session):
>> 
>> sink("ForRHelp.txt")
>> print(sessionInfo())
>> cat("\n")
>> print(.Platform)
>> time <-as.POSIXct(c( 126230400, 126252000, 126273600),
>> origin="2005-01-01", tz="GMT")
>> print(time)
>> cat(format(time[1], "%Y %m %d %H %M %S"), "\n")
>> cat(format(time[2], "%Y %m %d %H %M %S"), "\n")
>> cat(format(time[3], "%Y %m %d %H %M %S"), "\n")
>> sink()
>> print(paste("Text file in", getwd()))
>> 
>> and send the resulting txt file to the list (so we can see exactly
>> your system config and what not).
>> 
>> Michael
> 
> I appear to have the same or similar problem on Mac OS X 10.6.8
> I ran the above script with R --vanilla.
> The result is
> 
> R version 2.14.1 Patched (2012-01-30 r58238)
> Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
> 
> locale:
> [1] en_GB/en_GB/en_GB/C/en_GB/en_GB
> 
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base     
> 
> $OS.type
> [1] "unix"
> 
> $file.sep
> [1] "/"
> 
> $dynlib.ext
> [1] ".so"
> 
> $GUI
> [1] "X11"
> 
> $endian
> [1] "little"
> 
> $pkgType
> [1] "mac.binary.leopard"
> 
> $path.sep
> [1] ":"
> 
> $r_arch
> [1] "x86_64"
> 
> [1] "2009-01-01 00:00:00 GMT" "2009-01-01 06:00:00 GMT"
> [3] "2009-01-01 12:00:00 GMT"
> 2009 01 01 00 00 00 
> 2009 01 01 06 00 00 
> 2009 01 01 12 00 00 


Disregard my previous posting.
Results are correct.

Berend



More information about the R-help mailing list