ID: 27655
Updated by: [EMAIL PROTECTED]
Reported By: richardNO at SPAMPLEASEthe-moon dot net
-Status: Open
+Status: Verified
Bug Type: Date/time related
Operating System: Windows XP
PHP Version: 4.3.4
Previous Comments:
------------------------------------------------------------------------
[2004-03-19 06:32:00] richardNO at SPAMPLEASEthe-moon dot net
Description:
------------
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. I've created some code to illustrate. I only
came across this because it affects the Smarty date modifier.
-RichardW.
Reproduce code:
---------------
<?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);
}
?>
Expected result:
----------------
20040318010000 = -1 = ?
20040318020000 = -1 = ?
20040318030000 = -1 = ?
20040318040000 = -1 = ?
20040318050000 = -1 = ?
20040318060000 = -1 = ?
20040318070000 = -1 = ?
20040318080000 = -1 = ?
20040318090000 = -1 = ?
20040318100000 = 149986800 = 1974-10-03 (00:00:00)
20040318110000 = 181522800 = 1975-10-03 (00:00:00)
20040318120000 = 213145200 = 1976-10-03 (00:00:00)
20040318130000 = 244681200 = 1977-10-03 (00:00:00)
20040318140000 = 276217200 = 1978-10-03 (00:00:00)
20040318150000 = 307753200 = 1979-10-03 (00:00:00)
20040318160000 = 339375600 = 1980-10-03 (00:00:00)
20040318170000 = 370911600 = 1981-10-03 (00:00:00)
20040318180000 = 402447600 = 1982-10-03 (00:00:00)
20040318190000 = 433983600 = 1983-10-03 (00:00:00)
20040318200000 = 465606000 = 1984-10-03 (00:00:00)
20040318210000 = 497142000 = 1985-10-03 (00:00:00)
20040318220000 = 528678000 = 1986-10-03 (00:00:00)
20040318230000 = 560214000 = 1987-10-03 (00:00:00)
20040319000000 = -1 = ?
20040319010000 = -1 = ?
20040319020000 = -1 = ?
20040319030000 = -1 = ?
20040319040000 = -1 = ?
20040319050000 = -1 = ?
20040319060000 = -1 = ?
20040319070000 = -1 = ?
20040319080000 = -1 = ?
20040319090000 = -1 = ?
20040319100000 = -1 = ?
20040319110000 = -1 = ?
20040319120000 = -1 = ?
20040319130000 = -1 = ?
20040319140000 = -1 = ?
20040319150000 = -1 = ?
20040319160000 = -1 = ?
20040319170000 = -1 = ?
20040319180000 = -1 = ?
20040319190000 = -1 = ?
20040319200000 = -1 = ?
20040319210000 = -1 = ?
20040319220000 = -1 = ?
20040319230000 = -1 = ?
20040320000000 = -1 = ?
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=27655&edit=1