C++ converting string to time_t question
<p>Im trying to convert a string such as "12 August 2011" into time_t or that seconds elapsed, or whatever so I can use it to compare a list of dates.</p>

<p>At the moment, I have tried the following but the output seems to equal false! Also, the seconds elapsed seem to keep changing?</p>

<p>Is this correct?</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;cstdlib&gt;
#include &lt;cstring&gt;
#include &lt;time.h&gt;
#include &lt;stdio.h&gt;

using namespace std;

int main()
{

    struct tm tmlol, tmloltwo;
    time_t t, u;

    t = mktime(&amp;tmlol);
    u = mktime(&amp;tmloltwo);
    //char test[] = "01/01/2008";string test = "01/01/2008";

    strptime("10 February 2010", "%d %b %Y", &amp;tmlol);
    strptime("10 February 2010", "%d %b %Y", &amp;tmloltwo);

    t = mktime(&amp;tmlol);
    u = mktime(&amp;tmloltwo);

    cout &lt;&lt; t &lt;&lt; endl;
    cout &lt;&lt; u &lt;&lt; endl;

    if (u&gt;t)
    {
        cout &lt;&lt; "true" &lt;&lt; endl;
    }
    else if (u==t)
    {
        cout &lt;&lt; "same" &lt;&lt; endl;
    }
    else
    {
        cout &lt;&lt; "false" &lt;&lt; endl;
    }

    cout &lt;&lt; (u-t);
}
</code></pre>
