Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to convert "struct tm" to the time in seconds

76 views
Skip to first unread message

Juergen Beisert

unread,
Jul 4, 2009, 4:17:16 PM7/4/09
to
Hi,

does anybody know how to convert a time given in UTC in a "struct tm" into
the regular system time in seconds (also UTC)?

My problem is, my timezone is CET/CEST and "struct tm" is handled as a wall
clock (AFAIK). So, mktime() will convert the time with regard to my
timezone.
Is there a way to disable this (nice) feature? Or do I have to convert it by
myself to do a conversion UTC to UTC without timezone consideration?

Thanks in advance for some hints.
jbe

Alexander Bartolich

unread,
Jul 4, 2009, 5:15:04 PM7/4/09
to
Juergen Beisert schrieb:

> Hi,
>
> does anybody know how to convert a time given in UTC in a "struct tm" into
> the regular system time in seconds (also UTC)?

man timegm
# For a portable version of timegm(), set the TZ environment variable
# to UTC, call mktime(3) and restore the value of TZ.

--
seq 100 | sed 's/.*/Romani Ite Domum./'

Juergen Beisert

unread,
Jul 6, 2009, 3:31:24 AM7/6/09
to
Alexander Bartolich wrote:
> Juergen Beisert schrieb:

>> does anybody know how to convert a time given in UTC in a "struct tm"
>> into the regular system time in seconds (also UTC)?
>
> man timegm
> # For a portable version of timegm(), set the TZ environment variable
> # to UTC, call mktime(3) and restore the value of TZ.

I works with this "magic", thank you.

Juergen


0 new messages