Bug #53834 [NEW]: mktime returns wrong date if used zero prefix in day
| From: | jpachta at centrum dot cz | Date: | Tue, 25 Jan 2011 07:03:43 +0000 |
| Subject: | Bug #53834 [NEW]: mktime returns wrong date if used zero prefix in day | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-158156@lists.php.net to get a copy of this message | ||
From:
Operating system: WinXP
PHP version: 5.3.5
Package: Date/time related
Bug Type: Bug
Bug description:mktime returns wrong date if used zero prefix in day
Description:
------------
When used mktime() with parameters with zero prefix in days 2011-01-08 and
2011-01-09 the function returns timestamp for GMT: Thu, 30 Dec 2010
23:00:00 GMT
Example: note zeros in month and day parameters
mktime(0,0,0,01,08,2011)) returns wrong date GMT: Thu, 30 Dec 2010 23:00:00
GMT
mktime(0,0,0, 1,08,2011)) returns wrong date GMT: Thu, 30 Dec 2010 23:00:00
GMT
mktime(0,0,0, 1, 8,2011)) returns correct date
mktime(0,0,0,01, 8,2011)) returns correct date
Test script:
---------------
echo 'Current PHP version: ' . phpversion(); // Current PHP version: 5.3.5
date_default_timezone_set('Europe/Prague');
echo "------\r\n";
echo "2011-01-07 => ", date('Y-m-d', mktime(0,0,0,01,07,2011)), "
",
mktime(0,0,0,01,07,2011), " OK\r\n";
echo "2011-01-08 => ", date('Y-m-d', mktime(0,0,0,01,08,2011)), "
",
mktime(0,0,0,01,08,2011), " WR\r\n";
echo "2011-01-09 => ", date('Y-m-d', mktime(0,0,0,01,09,2011)), "
",
mktime(0,0,0,01,09,2011), " WR\r\n";
echo "2011-01-10 => ", date('Y-m-d', mktime(0,0,0,01,10,2011)), "
",
mktime(0,0,0,01,10,2011), " OK\r\n";
echo "------\r\n";
echo "2011-1-06 => ", date('Y-m-d', mktime(0,0,0,1,06,2011)), " ",
mktime(0,0,0,1,06,2011), " OK\r\n";
echo "2011-1-07 => ", date('Y-m-d', mktime(0,0,0,1,07,2011)), " ",
mktime(0,0,0,1,07,2011), " OK\r\n";
echo "2011-1-08 => ", date('Y-m-d', mktime(0,0,0,1,08,2011)), " ",
mktime(0,0,0,1,08,2011), " WR\r\n";
echo "2011-1-09 => ", date('Y-m-d', mktime(0,0,0,1,09,2011)), " ",
mktime(0,0,0,1,09,2011), " WR\r\n";
echo "2011-1-10 => ", date('Y-m-d', mktime(0,0,0,1,10,2011)), " ",
mktime(0,0,0,1,10,2011), " OK\r\n";
echo "------\r\n";
echo "2011-1-6 => ", date('Y-m-d', mktime(0,0,0,1,6,2011)), " ",
mktime(0,0,0,1,6,2011), " OK\r\n";
echo "2011-1-7 => ", date('Y-m-d', mktime(0,0,0,1,7,2011)), " ",
mktime(0,0,0,1,7,2011), " OK\r\n";
echo "2011-1-8 => ", date('Y-m-d', mktime(0,0,0,1,8,2011)), " ",
mktime(0,0,0,1,8,2011), " WR\r\n";
echo "2011-1-9 => ", date('Y-m-d', mktime(0,0,0,1,9,2011)), " ",
mktime(0,0,0,1,9,2011), " WR\r\n";
echo "2011-1-10 => ", date('Y-m-d', mktime(0,0,0,1,10,2011))," ",
mktime(0,0,0,1,10,2011), " OK\r\n";
echo "------\r\n";
echo "2011-01-6 => ", date('Y-m-d', mktime(0,0,0,01,6,2011)), " ",
mktime(0,0,0,1,6,2011), " OK\r\n";
echo "2011-01-7 => ", date('Y-m-d', mktime(0,0,0,01,7,2011)), " ",
mktime(0,0,0,1,7,2011), " OK\r\n";
echo "2011-01-8 => ", date('Y-m-d', mktime(0,0,0,01,8,2011)), " ",
mktime(0,0,0,1,8,2011), " WR\r\n";
echo "2011-01-9 => ", date('Y-m-d', mktime(0,0,0,01,9,2011)), " ",
mktime(0,0,0,1,9,2011), " WR\r\n";
echo "2011-01-10 => ", date('Y-m-d', mktime(0,0,0,01,10,2011)), "
",
mktime(0,0,0,1,10,2011), " OK\r\n";
Expected result:
----------------
In the test script above you can compare initial date and returned date. In
my case for days 08 and 09 it returned date of 2010-12-31 which is wrong.
--
Edit bug report at http://bugs.php.net/bug.php?id=53834&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=53834&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=53834&r=trysnapshot53
Try a snapshot (trunk): http://bugs.php.net/fix.php?id=53834&r=trysnapshottrunk
Fixed in SVN: http://bugs.php.net/fix.php?id=53834&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=53834&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=53834&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=53834&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=53834&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=53834&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=53834&r=support
Expected behavior: http://bugs.php.net/fix.php?id=53834&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=53834&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=53834&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=53834&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53834&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=53834&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=53834&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=53834&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=53834&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=53834&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=53834&r=mysqlcfg