> Evidently the strtotime() function will not convert an SQL datetime to a
> timestamp. Am I missing something? Here's an example of what I mean:
>
> $sql_datetime = '1948-30-03 01:30:00';
> $ts = strtotime( $sql_datetime );
> print( $ts.'<br>');
>
> When this script is executed, strtotime() returns -1.
>
> If true, that strtotime() is unable to convert SQL datetimes into
> timestamps, how are others accomplishing this?
>
> Cheers,
>
> Michael

>From http://us4.php.net/manual/en/function.strtotime.php a user comments
about this:

 cryogen at mac dot com
06-Apr-2004 09:39
I neglected to include the solution in my last post for using strtotime()
with date-time data stored in GMT.  Append the string "GMT" to all of your
datetimes pulled from MySQL or other database that store date-times in the
format "yyyy-mm-dd hh:ii:ss" just prior to converting them to a unix
timestamp with strtotime().  This will ensure you get a valid GMT result
for times during daylight savings.

EXAMPLE:
<?php
$date_time1 = strtotime("2004-04-04 02:00:00"); // returns bad value -1
due to DST
$date_time2 = strtotime("2004-04-04 02:00:00 GMT"); // works great!
?>


-- 
--Matthew Sims
--<http://killermookie.org>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to