#27655 [NEW]: Strtotime incorrectly recognises certain MySQL timestamps

From: Date: Fri, 19 Mar 2004 11:32:00 +0000
Subject: #27655 [NEW]: Strtotime incorrectly recognises certain MySQL timestamps
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-56669@lists.php.net to get a copy of this message
From: richardNO at SPAMPLEASEthe-moon dot net Operating system: Windows XP PHP version: 4.3.4 PHP Bug Type: Date/time related Bug description: Strtotime incorrectly recognises certain MySQL timestamps 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 bug report at http://bugs.php.net/?id=27655&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=27655&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=27655&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=27655&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=27655&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=27655&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=27655&r=needscript Try newer version: http://bugs.php.net/fix.php?id=27655&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=27655&r=support Expected behavior: http://bugs.php.net/fix.php?id=27655&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=27655&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=27655&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=27655&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27655&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=27655&r=dst IIS Stability: http://bugs.php.net/fix.php?id=27655&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=27655&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=27655&r=float

« previous php.bugs (#56669) next »