title: Understanding timezone strings in R
body: <p>I am having trouble understanding how timezone strings are handled in R and why <code>Sys.time()</code> uses a different string than <code>Sys.timezone()</code>?</p>
  
  <p><code>Sys.time()</code> returns:</p>
  
  <blockquote>
    <p>[1] "2016-05-13 10:17:04 CEST"</p>
  </blockquote>
  
  <p><code>as.POSIXct(Sys.time())</code> works:</p>
  
  <blockquote>
    <p>[1] "2016-05-13 10:17:11 CEST"</p>
  </blockquote>
  
  <p>And <code>as.POSIXct("2016-05-1 10:15:21 CEST")</code> works as well:</p>
  
  <blockquote>
    <p>[1] "2016-05-01 10:15:21 CEST"  </p>
  </blockquote>
  
  <p>However, <code>as.POSIXct("2016-05-1 10:15:21", tz = "CEST")</code> does <strong>NOT</strong> work:</p>
  
  <blockquote>
    <p>[1] "2016-05-01 10:15:21 GMT"<br>
    Warning messages:<br>
    1: In strptime(xx, f &lt;- "%Y-%m-%d %H:%M:%OS", tz = tz) :   unknown timezone 'CEST'<br>
    2: In as.POSIXct.POSIXlt(x) : unknown timezone 'CEST'<br>
    3: In strptime(x, f, tz = tz) : unknown timezone 'CEST'<br>
    4: In as.POSIXct.POSIXlt(as.POSIXlt(x, tz, ...), tz, ...) :   unknown timezone 'CEST'<br>
    5: In as.POSIXlt.POSIXct(x, tz) : unknown timezone
    'CEST'</p>
  </blockquote>
  
  <p>I know I can solve the issue with:  </p>
  
  <pre><code>Sys.timezone(location = TRUE)
  </code></pre>
  
  <blockquote>
    <p>[1] "Europe/Berlin"</p>
  </blockquote>
  
  <p>And <code>as.POSIXct("2016-05-1 10:15:21", tz = Sys.timezone(location = TRUE))</code> returns:</p>
  
  <blockquote>
    <p>[1] "2016-05-01 10:15:21 CEST"</p>
  </blockquote>
  
  <p>But I would like to understand why the above works like it does?
  And suppose I have data from a different timezone (say New York), how can I know which string to use?</p>
  
  <p><strong>Edit:</strong>
  The answer by Matt and Adams' link provided the answer to the second question: timezones can be looked on Wikipedia or by <code>lubridate::olson.time.zones</code>.</p>
  
  <p>However, the primary question is still unanswered: why is "2016-05-01 10:15:21 CEST" a valid <code>POSIXct class</code>, while <code>as.POSIXct("2016-05-1 10:15:21", tz = "CEST")</code> is not possible.</p>