Re: [Q] Converting SQL Datetimes to timestamps
| From: | John Holmes | Date: | Tue, 03 Aug 2004 18:23:42 +0000 |
| Subject: | Re: [Q] Converting SQL Datetimes to timestamps | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-192578@lists.php.net to get a copy of this message | ||
Michael T. Peterson wrote:
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?strtotime() will work, actually, but not for dates before 1970. If you want to convert a database timestamp to a Unix timestamp that's before 1970, you need to be on an OS that supports negative timestamps (not windows, as far as I know). -- John Holmes php|architect - The magazine for PHP professionals - http://www.phparch.com