Re: UTC string -> time_t
- From: Nick Keighley <nick_keighley_nospam@xxxxxxxxxxx>
- Date: Tue, 18 Dec 2007 06:47:24 -0800 (PST)
On 18 Dec, 13:41, Nick Keighley <nick_keighley_nos...@xxxxxxxxxxx>
wrote:
Hi,
this is probably quite easy...
How do I convert a UTC string into a time_t?
eg. "2007-12-18 13:37:26" -> a time_t.
Now FAQ 13.3 says use mktime() to convert a struct tm into
a time_t or you have to use some non-standard thing to parse the
string.
Assume I can parse the string and build a struct tm, how can I turn
it
into a time_t?
mktime() works on *local time* so it is going to apply the timezone
change
(the incoming string may have come from another timezone).
to save anyone the trouble of answering it looks like the way to
go is to calculate the difference between local time and UTC
by using difftime() on the results of localtime() and gmtime().
Adjusting the input value in struct tm then using mktime().
eek!
--
Nick Keighley
.
- Follow-Ups:
- Re: UTC string -> time_t
- From: Eric Sosman
- Re: UTC string -> time_t
- References:
- UTC string -> time_t
- From: Nick Keighley
- UTC string -> time_t
- Prev by Date: Re: c calling c++ functions
- Next by Date: Print a signel octal
- Previous by thread: UTC string -> time_t
- Next by thread: Re: UTC string -> time_t
- Index(es):
Relevant Pages
|