php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55327 mktime produces different results with different formats
Submitted: 2011-07-31 06:27 UTC Modified: 2011-07-31 06:34 UTC
From: ahemphill at clickbusinessservices dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.3.6 OS: Linux
Private report: No CVE-ID: None
 [2011-07-31 06:27 UTC] ahemphill at clickbusinessservices dot com
Description:
------------
For August 1, 2011, mktime produces different results based on the input format of the month parameter.  Sounds goofy, yes.  
But calculations based on whether the Aug 1 date is in the future or past may fail if a leading zero is entered for the month.



Test script:
---------------
echo 'mktime (0,0,0,8,01,2011)  = '.mktime (0,0,0,8,01,2011). '<br />';
echo 'mktime (0,0,0,08,01,2011)  = '.mktime (0,0,0,08,01,2011). '<br />';
echo 'mktime (0,0,0,7,01,2011)  = '.mktime (0,0,0,7,01,2011). '<br />';
echo 'mktime (0,0,0,07,01,2011)  = '.mktime (0,0,0,07,01,2011). '<br />';

Expected result:
----------------
mktime (0,0,0,8,01,2011) = 1312171200
mktime (0,0,0,08,01,2011) = 1312171200
mktime (0,0,0,7,01,2011) = 1309492800
mktime (0,0,0,07,01,2011) = 1309492800

Actual result:
--------------
mktime (0,0,0,8,01,2011) = 1312171200
mktime (0,0,0,08,01,2011) = 1291179600   <- value is too small
mktime (0,0,0,7,01,2011) = 1309492800
mktime (0,0,0,07,01,2011) = 1309492800

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-07-31 06:34 UTC] rasmus@php.net
-Status: Open +Status: Bogus
 [2011-07-31 06:34 UTC] rasmus@php.net
Numbers with leading 0's are octal. 08 is an invalid value. See 
http://php.net/integer
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 03 19:01:32 2024 UTC