libdbi-users

[Prev] Thread [Next]  |  [Prev] Date [Next]

Re: [libdbi-users] UNIX Timestamp - DATE to UTC conversion Markus Hoenicka Wed Nov 19 07:00:19 2008

Quoting Ken Ramsay <[EMAIL PROTECTED]>:

>
> Thanks guys,
>
> MySQL defines the field as a DATETIME , so the return type is time_t. As
> far as I could find out, there is no helper funtion to convert this into
> secs from 1 Jan 1970 , so I got around it by using the difftime() call
> and subtracting the returned value from 1/1/1970. difftime() returns the
> difference in seconds.
>
> Not sure it is the most elegant way to do it but it works ...;-}
>

Ah, I see. libdbi provides a dbi_result_get_datetime() function to  
retrieve these time_t values. Unless you have to do it in SQL, you  
could then post-process this value using gmtime() or any other  
suitable Unix time function.

regards,
Markus


-- 
Markus Hoenicka
[EMAIL PROTECTED]
(Spam-protected email: replace the quadrupeds with "mhoenicka")
http://www.mhoenicka.de


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
libdbi-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/libdbi-users