title: Convert MySQL Datetime to C++ std::time_t
body: <p>I am stuck in a problem and really hope you can help me. I like to convert a MySQL <code>DATETIME</code> field into a C++ <code>std::time_t</code> variable. My database looks like this:</p>
  
  <pre><code>CREATE TABLE data(
      id              INTEGER       AUTO_INCREMENT UNIQUE,
      path            VARCHAR(1000),
      acquisitionDate DATETIME
  );
  </code></pre>
  
  <p>And I am trying to  save the value from <code>acquisitionDate</code> into a c++ variable of type <code>std::time_t</code>.</p>
  
  <p>After some web searching I learned that I have to use <code>UNIX_TIMESTAMP</code> in my MySQL statement. However, I did not understand how to actual use it. I can generate a query and receive a <code>sql::ResultSet</code>:</p>
  
  <pre><code>std::unique_ptr&lt;sql::Statement&gt; stmt(mConnection-&gt;createStatement());
  
  std::string query="SELECT id, path, UNIX_TIMESTAMP(acquisitionDate) FROM data WHERE id = 1";
  
  std::unique_ptr&lt;sql::ResultSet&gt; res(stmt-&gt;executeQuery(query));
  </code></pre>
  
  <p>But I don't understand how I can get the actual field value into a <code>std::time_t</code> variable</p>
  
  <pre><code>if(res-&gt;next())
  {
      std::time_t acquisitionDate =  res-&gt;getInt("acquisitionDate");
      std::time_t acquisitionDate =  res-&gt;???
  }
  </code></pre>
  
  <p>Somehow my brain does not get this last step. Please help me.
  Thank you very much!</p>