title: Google Maps Time Zone API get local time in UTC
body: <h1>Google Docs says:</h1>
  
  <blockquote>
    <p>The local time of a given location is the sum of the timestamp parameter, and the dstOffset and rawOffset fields from the result.</p>
  </blockquote>
  
  <p>timestamp + dstOffset + rawOffset = local time in seconds in UTC</p>
  
  <h1>Problem</h1>
  
  <p>I am trying to get the local time in the correct time zone.
  I thought that new Date(timestamp + dstOffset + rawOffset *1000) would return the local time in UTC, but instead I find that the actual numerical values are indeed in local time, in the wrong time zone (UTC).</p>
  
  <h1>Example:</h1>
  
  <p><strong>timestamp:</strong> 1456349190</p>
  
  <p><strong>readable timestamp:</strong> <code>new Date(1456349190*1000).toGMTString()</code> (Wed, 24 Feb 2016 21:26:30 GMT)</p>
  
  <p><code>https://maps.googleapis.com/maps/api/timezone/json?location=39.2079206,-84.5274616&amp;timestamp=1456349190&amp;key=${googleApiKey}</code></p>
  
  <p><em>Returns:</em></p>
  
  <ul>
  <li><strong>dstOffset</strong>:  0 </li>
  <li><strong>rawOffset</strong>:  -18000</li>
  <li><strong>timeZoneId</strong>: America/New_York</li>
  </ul>
  
  <p><em>Data:</em></p>
  
  <p><strong>Sum in seconds</strong> = 1456349190 + 0 + (-18000) = 1456331190</p>
  
  <p><strong>Sum in milliseconds</strong> = 1456331190*1000 = 1456331190000</p>
  
  <p><strong>Supposed Local Date</strong> = <code>new Date(1456331190000).toGMTString()</code> (Wed, 24 Feb 2016 16:26:30 GMT)</p>
  
  <h1>Question</h1>
  
  <p>Shouldn't <strong>readable timestamp</strong> and <strong>Supposed Local Date</strong> be the same since both are in UTC?
  Seems like <strong>Supposed Local Date</strong> should really be Wed, 24 Feb 2016 16:26:30 <strong>EST</strong></p>
  
  <p>Is this correct?</p>
  
  <p>If so it seems like I just need to extract the values I need (local hour) from <strong>Supposed Local Date</strong> and apply the correct time zone returned from google api <strong>timeZoneId</strong> (America/New_York) because 16:26:30 is the correct local time I need.</p>
  
  <h1>Helpful Tips</h1>
  
  <p>These are some guidelines that helped me understand timestamp better:</p>
  
  <p>"<a href="https://stackoverflow.com/a/8668144/3483001">The unix timestamp isn't affected by a timezone setting. Setting the timezone only affects the interpretation of the timestamp value.</a>"</p>