note 40928 added to function.strtotime
| From: | RichardWall at rn2 dot php dot net | Date: | Fri, 19 Mar 2004 11:25:46 +0000 |
| Subject: | note 40928 added to function.strtotime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-67055@lists.php.net to get a copy of this message | ||
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.
----
Manual Page -- http://www.php.net/manual/en/function.strtotime.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+40928
Delete -- http://master.php.net/manage/user-notes.php?action=delete+40928&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+40928&report=yes
Search -- http://master.php.net/manage/user-notes.php