title: Convert Date to Integer C++
body: <p>I have the following code to convert from a date in a <code>string</code> to an <code>integer</code></p>
  
  <pre><code>#include &lt;sstream&gt;
  #include &lt;string&gt;
  #include &lt;ctime&gt;
  
  typedef long long int llint;
  
  llint stringDate2LLInt(std::string date, std::string format)
  {
      std::stringstream ss(date);
      std::tm dt;
      ss &gt;&gt; std::get_time(&amp;dt, format.c_str());
      std::time_t tt = std::mktime(&amp;dt);
      return tt;
  }
  
  int main()
  {
      std::string date("9/29/2014 17:48");
      std::string format("%m/%d/%Y %H:%M");
      std::cout &lt;&lt; date &lt;&lt; "-&gt;" &lt;&lt; stringDate2LLInt(date, format) &lt;&lt; std::endl;
      std::cout &lt;&lt; date &lt;&lt; "-&gt;" &lt;&lt; stringDate2LLInt(date, format) &lt;&lt; std::endl;
      std::cout &lt;&lt; date &lt;&lt; "-&gt;" &lt;&lt; stringDate2LLInt(date, format) &lt;&lt; std::endl;
  
      return 0;
  }
  </code></pre>
  
  <p>however, calling it with the same value for the arguments, i.e. <code>"9/29/2014 17:48"</code> and <code>"%m/%d/%Y %H:%M"</code> the result is different each time. Why is this happening?</p>
  
  <p>What I wanted to do is to get the number of miliseconds (or maybe seconds) since <code>00:00 hours, Jan 1, 1970 UTC</code> for a given <code>date</code>. Any way I can do this?</p>