Reputation: 785
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?
Upvotes: 1
Views: 398
Reputation: 18749
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"
Upvotes: 1