How do I do the above? There is mktime function but that treats the input as expressed in local time but how do i perform the conversion if my input tm variable happens to be in UTC.
From stackoverflow
-
Use timegm() instead of mktime()
Jonathan Leffler : Good answer - only demerit is that it is a non-standard (as in, not in POSIX or C standard) function.Michael Burr : I've seen other answers on the net that talk about getting the timezone offset using something like (note this is pseudo code - the parameters aren't right): difftime( mktime( gmtime( time())), mktime( localtime( time()))). But no one ever says how you apply this offset to your time_t variable.: Does this work in windows too?
0 comments:
Post a Comment