C++ - Timezone conversion
<p>I've the following piece of code to find the difference between the UTC and local time zone. </p>

<pre><code>struct tm *local_time, *gmt_time;
    time_t t = time(NULL);
    local_time = localtime(&amp;t);
    gmt_time = gmtime(&amp;t);
    int y = mktime(local_time);
    int x = mktime(gmt_time);       
    tzone_diff = y - x;
</code></pre>

<p>This doesn't work. However if i move the statement gmt_time = gmtime(&amp;t) below int y = mktime(local_time); it works. That is the following piece of code works:</p>

<pre><code>struct tm *local_time, *gmt_time;
time_t t = time(NULL);
local_time = localtime(&amp;t);
int y = mktime(local_time);
gmt_time = gmtime(&amp;t);
int x = mktime(gmt_time);       
tzone_diff = y - x;
</code></pre>

<p>This seems wierd to me.. Any clues?</p>
