G
Generic Usenet Account
I am trying to find the best way to get the difference between UTC and
the local time? Here's a small code snippet that I have written for
this purpose. Is there a better way to do this?
Thanks,
Bala
/*************************************************************************/
time_t getTimeOffset()
{
struct tm *gmTime;
time_t localEpoch, gmEpoch;
/*First get local epoch time*/
localEpoch = time(NULL);
/* Using local time epoch get the GM Time */
gmTime = gmtime(&localEpoch);
/* Convert gm time in to epoch format */
gmEpoch = mktime(gmTime);
/* get the absolute different between them */
return abs(gmEpoch - localEpoch);
}
the local time? Here's a small code snippet that I have written for
this purpose. Is there a better way to do this?
Thanks,
Bala
/*************************************************************************/
time_t getTimeOffset()
{
struct tm *gmTime;
time_t localEpoch, gmEpoch;
/*First get local epoch time*/
localEpoch = time(NULL);
/* Using local time epoch get the GM Time */
gmTime = gmtime(&localEpoch);
/* Convert gm time in to epoch format */
gmEpoch = mktime(gmTime);
/* get the absolute different between them */
return abs(gmEpoch - localEpoch);
}