0
Sys.timezone()

[1] "CST"

as.POSIXct("2012-12-12",tz="CST")

[1] "2012-12-12 GMT"

There were 13 warnings (use warnings() to see them)

I've set tz to CST, but the output is GMT, with warning messages, what went wrong?

Edit:

My OS is windows 7

warnings are:

Warning messages:
1: In strptime(xx, f <- "%Y-%m-%d %H:%M:%OS", tz = tz) : unknown timezone 'CST'
2: In as.POSIXct.POSIXlt(x) : unknown timezone 'CST'
3: In strptime(xx, f <- "%Y/%m/%d %H:%M:%OS", tz = tz) : unknown timezone 'CST'
4: In as.POSIXct.POSIXlt(x) : unknown timezone 'CST'
5: In strptime(xx, f <- "%Y-%m-%d %H:%M", tz = tz) : unknown timezone 'CST'
6: In as.POSIXct.POSIXlt(x) : unknown timezone 'CST'
7: In strptime(xx, f <- "%Y/%m/%d %H:%M", tz = tz) : unknown timezone 'CST'
8: In as.POSIXct.POSIXlt(x) : unknown timezone 'CST'
9: In strptime(xx, f <- "%Y-%m-%d", tz = tz) : unknown timezone 'CST'
10: In as.POSIXct.POSIXlt(x) : unknown timezone 'CST'
11: In strptime(x, f, tz = tz) : unknown timezone 'CST'
12: In as.POSIXct.POSIXlt(as.POSIXlt(x, tz, ...), tz, ...) :
  unknown timezone 'CST'
13: In as.POSIXlt.POSIXct(x, tz) : unknown timezone 'CST'
ChaoYang
  • 837
  • 2
  • 8
  • 14
  • Also, the time zones are system dependent so we need your OS. – stanekam Mar 27 '14 at 04:38
  • @iShouldUseAName I've edit the post, add warnings and OS information. – ChaoYang Mar 27 '14 at 06:51
  • Please read [the timezone tag wiki](http://stackoverflow.com/tags/timezone/info), the sections on the IANA time zone database and on POSIX time zones in particular. I don't know enough about R to answer, but I know you should avoid posix time zones. Also, there are at least [5 different meanings of "CST"](http://en.wikipedia.org/wiki/List_of_time_zone_abbreviations). If R supports it, you should use IANA time zone identifiers, like `America/Chicago`. – Matt Johnson-Pint Mar 27 '14 at 08:42
  • The _See Also_ section of `?as.POSIXct` tells you to read `?Sys.timezone` to learn about the system-specific details of timezone implementations and how to specify valid strings. – Joshua Ulrich Mar 27 '14 at 14:00
  • Hi, I am OP, the problem is solved, I have added my solution below, sorry didn't tell you about that. – ChaoYang Mar 28 '14 at 04:51

2 Answers2

0

try

as.POSIXct("2012-12-12",tz="CST6CDT")

Answer came from: unknown timezone name in R strptime/as.POSIXct

Community
  • 1
  • 1
RJ-
  • 2,919
  • 3
  • 28
  • 35
0

I have found the list of valid names for tz parameter, they are all in the table in this web http://en.wikipedia.org/wiki/List_of_tz_database_time_zones in the column of the name "TZ".

ChaoYang
  • 837
  • 2
  • 8
  • 14
  • Those aren't necessarily valid names. As it says in the _See Also_ sections of `?as.POSIXct`, `?Sys.timezone` tells you how to determine the valid names on your specific system. – Joshua Ulrich Mar 27 '14 at 13:57