title: How to get datetime in ISO 8601 format on Windows?
body: <p>What's a standard way to get a date time in <a href="https://en.wikipedia.org/wiki/ISO_8601" rel="nofollow noreferrer">ISO8601</a> format on Windows using C++?  Specifically, I would like it to be formatted as: </p>
  
  <p><code>
  2017-02-22T10:00:00.123-05:00
  2017-02-22T10:00:00.123   &gt;&gt;&gt; -05:00 &lt;&lt;&lt;    # how to print the offset?
  </code></p>
  
  <p>I was looking into combining the output of <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms724338%28v=vs.85%29.aspx" rel="nofollow noreferrer"><code>GetLocalTime</code></a> and <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms724421(v=vs.85).aspx" rel="nofollow noreferrer"><code>GetTimeZoneInformation</code></a>, but this looks esoteric. There are similar questions on SO, however, I've not found a single one that prints UTC offset in a desired format. Is there a better approach?</p>