note 40928 deleted from function.strtotime by aidan
| From: | aidan@php.net | Date: | Wed, 11 Aug 2004 18:23:26 +0000 |
| Subject: | note 40928 deleted from function.strtotime by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-74492@lists.php.net to get a copy of this message | ||
Note Submitter: Richard Wall
----
Usually strtotime doesn't recognise MySQL timestamps and returns -1. I noticed though that for
some hours of 2004-03-18 it suddenly started returning a timestamp. Code to illustrate...
---
<?php
/**
* Generates MySQL timestamps over 48 hours from 2004-03-18
* Displays results of PHP strtotime on MySql timestamps over that period
**/
for( $i=1; $i<=48; $i++ )
{
$unixTimeStamp = mktime($i,0,0,3,18,2004);
$mysqlTimeStamp = strftime('%Y%m%d%H%M%S', $unixTimeStamp);
$strToTimeStamp = strtotime($mysqlTimeStamp);
$displayDate = '?';
if ($strToTimeStamp != -1)
{
$displayDate = strftime('%Y-%m-%d (%H:%M:%S)', $strToTimeStamp);
}
printf('<p>%s = %s = %s</p>', $mysqlTimeStamp, $strToTimeStamp,
$displayDate);
}
?>
---
...I only came across this because it affects the Smarty date modifier.
-RichardW.