1

I have datetime values like

val <- c(1376517610, 1376519412, 1376528711, 1376528411, 1376528411)

I wan't to convert these values to datetime and I'm trying this using

> as.POSIXct(val, tz="EEST", origin = '1970-01-01 00:00:00')
[1] "2013-08-14 22:00:10 GMT" "2013-08-14 22:30:12 GMT" "2013-08-15 01:05:11 GMT"
[4] "2013-08-15 01:00:11 GMT" "2013-08-15 01:00:11 GMT"
Warning messages:
1: In strptime(xx, f <- "%Y-%m-%d %H:%M:%OS", tz = tz) :
  unknown timezone 'EEST'
2: In as.POSIXct.POSIXlt(x) : unknown timezone 'EEST'
3: In strptime(x, f, tz = tz) : unknown timezone 'EEST'
4: In as.POSIXct.POSIXlt(as.POSIXlt(x, tz, ...), tz, ...) :
  unknown timezone 'EEST'
5: In as.POSIXlt.POSIXct(x, tz) : unknown timezone 'EEST'

But my timezone is EEST

> Sys.timezone()
[1] "EEST"

How to solve this problem and convert this data into the right timezone?

Matkrupp
  • 781
  • 5
  • 12
  • 17
  • 3
    Have you tried using a full Olson time zone ID, e.g. "America/New_York"? – Jon Skeet Aug 15 '13 at 18:52
  • Related to [Check if a timezone is valid in R](http://stackoverflow.com/q/17345516/271616) – Joshua Ulrich Aug 15 '13 at 18:55
  • Your code works without problem on my system. Could it be a system specific issue? What operating system are you using? – f3lix Aug 15 '13 at 19:00
  • 1
    Thanks, I tried to use my timezone using that format (Europe/Helsinki) but it is still 2 hours less than it should be. – Matkrupp Aug 15 '13 at 19:02
  • I can't replicate a 2 hour difference on Win7 Enterprise. Using my current local time in Australia and transferring to Helsinki via: `as.POSIXct(as.numeric(Sys.time()), tz="Europe/Helsinki", origin = '1970-01-01')` matches the time for Helsinki reported by Google. – thelatemail Aug 15 '13 at 23:10

1 Answers1

1

As was the case for this question, you shouldn't specify the daylight saving time timezone, just use the normal timezone, the system will understand it is summer time because of the date:

as.POSIXct(val, tz="EET", origin = '1970-01-01 00:00:00')
[1] "2013-08-14 23:00:10 EEST" "2013-08-14 23:30:12 EEST" "2013-08-15 02:05:11 EEST" "2013-08-15 02:00:11 EEST" "2013-08-15 02:00:11 EEST"

NB: I posted this answer because I think it resolves the "unknown timezone" issue. However there is indeed still the issue that it appears as UTC +1 when it should be UTC +3. Using "Europe/Helsinki" gives the same error (at least for me on Mac OS X 10.6 and R 2.14.2, with french locale):

as.POSIXct(val, tz="Europe/Helsinki", origin = '1970-01-01 00:00:00')
[1] "2013-08-14 23:00:10 EEST" "2013-08-14 23:30:12 EEST" "2013-08-15 02:05:11 EEST" "2013-08-15 02:00:11 EEST" "2013-08-15 02:00:11 EEST"
Community
  • 1
  • 1
plannapus
  • 18,529
  • 4
  • 72
  • 94