title: Create std::wstring with date
body: <p>I'm looking for the go-to way to create a formatted (MySQL DATETIME compatible that is) <code>std::wstring</code> from a <code>std::time_t</code>. What I do at the moment is to create a <code>std::string</code> with <code>std::put_time</code> from a <code>std::stringstream</code>, then transform it to <code>std::wstring</code> on construction like this:</p>
  
  <p><code>std::wstring foo(myStdString.begin(), myStdString.end())</code></p>
  
  <p>But I feel this is not very elegant. Ist there an established way of doing this? Some way of retrieving in a form using wide characters all along maybe?</p>
  
  <p><strong>Answer (see below)</strong></p>
  
  <p>I forgot to specify the format string for <code>std::put_time</code> in the right format, then it works similar to <code>std::string</code>.</p>
  
  <p>This is my resulting code:</p>
  
  <pre><code>auto time_last_write = boost::filesystem::last_write_time(path);
  std::wostringstream wstream;
  wstream &lt;&lt; std::put_time(std::gmtime(&amp;time_last_write), L"%Y-%M-%d %H:%M:%S");
  </code></pre>