title: Convert date to unix time stamp in c++
body: <p>As some websites that convert those unix time stamps say, the stamp of </p>
  
  <pre><code>2013/05/07 05:01:00 (yyyy/mm/dd, hh:mm:ss) is 1367902860.
  </code></pre>
  
  <p>The way I do it in C++, the stamp differs from the date. 
  Here is the code:</p>
  
  <pre><code>time_t rawtime;
  struct tm * timeinfo;
  
  int year=2013, month=5, day=7, hour = 5, min = 1, sec = 0;
  
  /* get current timeinfo: */
  time ( &amp;rawtime ); //or: rawtime = time(0);
  /* convert to struct: */
  timeinfo = localtime ( &amp;rawtime ); 
  
  /* now modify the timeinfo to the given date: */
  timeinfo-&gt;tm_year   = year - 1900;
  timeinfo-&gt;tm_mon    = month - 1;    //months since January - [0,11]
  timeinfo-&gt;tm_mday   = day;          //day of the month - [1,31] 
  timeinfo-&gt;tm_hour   = hour;         //hours since midnight - [0,23]
  timeinfo-&gt;tm_min    = min;          //minutes after the hour - [0,59]
  timeinfo-&gt;tm_sec    = sec;          //seconds after the minute - [0,59]
  
  /* call mktime: create unix time stamp from timeinfo struct */
  date = mktime ( timeinfo );
  
  printf ("Until the given date, since 1970/01/01 %i seconds have passed.\n", date);
  </code></pre>
  
  <p>The resulting time stamp is</p>
  
  <pre><code>1367899260, but not 1367902860.
  </code></pre>
  
  <p>What is the problem here? Even if I change to hour-1 or hour+1, it does not match. EDIT: Well yes if i add 1 to hour, it works. previously also added 1 to minutes.</p>