#40744 [NEW]: possible mktime bug?

From: Date: Wed, 07 Mar 2007 06:25:37 +0000
Subject: #40744 [NEW]: possible mktime bug?
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-110022@lists.php.net to get a copy of this message
From: jeffkoston22 at yahoo dot com Operating system: Slackware 11 PHP version: 5.2.1 PHP Bug Type: Date/time related Bug description: possible mktime bug? Description: ------------ I'm not really fond of mktime() but I needed a way of taking two dates in MySQL format and seeing which date is older... ie: $date = "2007-03-01"; if ($date <= date('Y-m-d')) { print "Expired"; } else { print "Not Expired"; } I know you can't use dates like that in the condition so I used date('U') and mktime() to give me the seconds since the Unix Epoch but I decided to test using different date formats first just to see how mktime handles months and years that might or might not have leading zero's.. notice the difference in seconds with the year 08 vs. 07 please correct me if I'm doing something stupid here that I should not be doing. I don't quite understand Bug #25050 - is this the same situation? thanks for your time! Reproduce code: --------------- print "test1: " . date('U', mktime(0, 0, 0, 3, 1, 2008)) . "<br />"; // 3-1-2008 returned 1204261200 print "test2: " . date('U', mktime(0, 0, 0, 3, 1, 08)) . "<br />"; // 3-1-08 returned 951800400 print "test3: " . date('U', mktime(0, 0, 0, 03, 1, 2008)) . "<br />"; // 03-1-2008 returned 1204261200 print "test4: " . date('U', mktime(0, 0, 0, 03, 1, 08)) . "<br />"; // 03-1-08 returned 951800400 print "test5: " . date('U', mktime(0, 0, 0, 3, 1, 2007)) . "<br />"; // 3-1-2007 returned 1172638800 print "test6: " . date('U', mktime(0, 0, 0, 3, 1, 07)) . "<br />"; // 3-1-07 returned 1172638800 print "test7: " . date('U', mktime(0, 0, 0, 03, 1, 2007)) . "<br />"; // 03-1-2007 returned 1172638800 print "test8: " . date('U', mktime(0, 0, 0, 03, 1, 07)) . "<br />"; // 03-1-07 returned 1172638800 test1: 1204347600 test2: 951886800 test3: 1204347600 test4: 951886800 test5: 1172725200 test6: 1172725200 test7: 1172725200 test8: 1172725200 Expected result: ---------------- I expected to see: test1: 1204347600 test2: 1204347600 test3: 1204347600 test4: 1204347600 test5: 1172725200 test6: 1172725200 test7: 1172725200 test8: 1172725200 Actual result: -------------- instead I got: test1: 1204347600 test2: 951886800 test3: 1204347600 test4: 951886800 test5: 1172725200 test6: 1172725200 test7: 1172725200 test8: 1172725200 -- Edit bug report at http://bugs.php.net/?id=40744&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=40744&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=40744&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=40744&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=40744&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=40744&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=40744&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=40744&r=needscript Try newer version: http://bugs.php.net/fix.php?id=40744&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=40744&r=support Expected behavior: http://bugs.php.net/fix.php?id=40744&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=40744&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=40744&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=40744&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=40744&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=40744&r=dst IIS Stability: http://bugs.php.net/fix.php?id=40744&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=40744&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=40744&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=40744&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=40744&r=mysqlcfg

« previous php.bugs (#110022) next »