R: Posix (Unix) Time Crazy Conversion -


unix time 1435617000.

as.date(1435617000,origin="01-01-1970") [1] "3930586-11-23" 

which wrong. i'm trying (a) correct date, which, per epoch converter gmt: mon, 29 jun 2015 22:30:00 gmt.

how r tell me month, day, year, hour, minute & second? thank you.

i think reason why happen because as.date converts arguments class date objects. in case not need date class posixct object because input, x vector, contains other informations as.date not able manage. problem right function appear, if when not specify right time zone tz argument (except case time zone same original time).

the following code job.

x <- 1435617000 as.posixct(x, origin = "1970-01-01", tz ="gmt") [1] "2015-06-29 22:30:00 gmt" 

use as.date

just in case wanted date have complete unix time x, have divide 86400 (which number of seconds in day!) right date.

 as.date(x/86400l, origin = "1970-01-01") [1] "2015-06-29" 

another important detail

the origin argument has supplied yyyy-mm-dd , not did dd-mm-yyyy not sure think former accepted , correct way.


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -