preethi gnanesh
preethi gnanesh

Reputation: 41

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 ?

Upvotes: 0

Views: 281

Answers (2)

Akshay
Akshay

Reputation: 86

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

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

Upvotes: 1

Rohit
Rohit

Reputation: 2017

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"

Upvotes: 0

Related Questions