1

I am trying to convert epoch time to date. I have a numeric array with epoch times.

I tried this -

print(as.POSIXct(x), origin = "1970-01-01", tz = "CST6CDT"))

Where x represents the numeric array with epoch times

#Output:
" CDT" " CST" " CDT" " CDT" " CDT" " CST" " CDT" " CST"

I have tried these-

print(as.POSIXct(1403878908842, origin = "1970-01-01", tz = "CST6CDT"))
print(as.POSIXct(1403878908842, origin = "1970-01-01", tz = ""))

But they all return timezones not the converted date.

thelatemail
  • 91,185
  • 12
  • 128
  • 188
Sugandha
  • 85
  • 7
  • this is nearly verbatim http://stackoverflow.com/questions/13456241/convert-unix-epoch-to-date-object-in-r – rawr Jul 07 '14 at 22:27

1 Answers1

2

Try this:

as.POSIXct(1403878908842/1000, origin = "1970-01-01", tz = "")
## [1] "2014-06-27 10:21:48 EDT"

as.POSIXct(1403878908842/1000, origin = "1970-01-01", tz = "CST6CDT")
## [1] "2014-06-27 09:21:48 CDT"
G. Grothendieck
  • 254,981
  • 17
  • 203
  • 341