Re: how to convert ascii time to seconde ( epoch time )

From: Måns Rullgård (mru_at_inprovide.com)
Date: 03/01/05


Date: Tue, 01 Mar 2005 01:37:57 +0100

John Fusco <fusco_john@yahoo.com> writes:

> Josef Moellers wrote:
>> google-rambo88 wrote:
>>
>>> Hello.
>>> time_t t;
>>> struct tm * tblock;
>>> t = time ( NULL );
>>> tblock = localtime(&t);
>>>
>>> printf( "long = %ld , Local time is: %s", t1, asctime(tblock)) );
>>> ==>Sun Sep 16 01:03:52 1973
>>>
>>> I'd like to know how to convert ascii time to epoch time(second).
>>> namely , Sun Sep 16 01:03:52 1890 ==> epoch time in second?
>> You'll need to convert the string into a struct tm and then call
>> mktime().
>
> You might want to look at Python's strptime() in the time package.

Anything wrong with strptime() in C?

-- 
Måns Rullgård
mru@inprovide.com


Relevant Pages

  • Re: UTC string -> time_t
    ... How do I convert a UTC string into a time_t? ... Now FAQ 13.3 says use mktime() to convert a struct tm into ... Assume I can parse the string and build a struct tm, ... objects to get the offset in minutes. ...
    (comp.lang.c)
  • Re: UTC string -> time_t
    ... How do I convert a UTC string into a time_t? ... Now FAQ 13.3 says use mktime() to convert a struct tm into ... Assume I can parse the string and build a struct tm, ...
    (comp.lang.c)
  • Re: UTC string -> time_t
    ... How do I convert a UTC string into a time_t? ... Now FAQ 13.3 says use mktime() to convert a struct tm into ... The PostgreSQL code base is Berkeley licensed and has date/time ...
    (comp.lang.c)
  • UTC string -> time_t
    ... How do I convert a UTC string into a time_t? ... Now FAQ 13.3 says use mktime() to convert a struct tm into ... Assume I can parse the string and build a struct tm, ... (the incoming string may have come from another timezone). ...
    (comp.lang.c)
  • Re: Weird time-zone oscillation
    ... You know, struct tm doesn't need to be zeroed before strptime(), that's ... But if that's how your libc behaves, ... it will know it has to detect DST itself. ... means "no DST" and mktime will not verify it. ...
    (Debian-User)