简体   繁体   中英

as.POSIXCt returning incorrect date value in R

I am trying to convert the Eopch time interval using as.POSIXct function in R into the local timezone and in the Europe/Vienna timezone. But for both the timezone its displaying a weird date

as.POSIXct(1385856600000, origin = "1970-01-01", tz='CET')
[1] "45886-01-17 23:40:00 CET"
> as.POSIXct(1385856600000, origin = "1970-01-01")
[1] "45886-01-18 04:10:00 IST"

What i am typing wrong here ?

you can use anytime package too.. much simpler to use than as.POSIXCt

anytime(1385856600000/1000)
[1] "2013-12-01 05:40:00 IST"

I think that your time is in milliseconds. If you divide by 1000, you get:

as.POSIXct(1385856600, origin = "1970-01-01")
[1] "2013-12-01 05:40:00 IST"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM