php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62364 Strange behaviour in mktime() function using leading zeros
Submitted: 2012-06-19 09:52 UTC Modified: 2012-06-19 10:59 UTC
From: praflo at gmail dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: Irrelevant OS: gentoo linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: praflo at gmail dot com
New email:
PHP Version: OS:

 

 [2012-06-19 09:52 UTC] praflo at gmail dot com
Description:
------------
In the mktime() function if you add a "0" before the number of the month of August or September (eg. august -> 08) the result is something wrong. See example below.
It seems this happens only with "08" and "09", not with "07", "06", etc.

I discovered this because August 12th 2012 (08-12-2012) is the last day of the next Olympic games in London.

Hope this helps
bye
gian

(PHP version: PHP 5.3.8-pl0-gentoo)







Test script:
---------------
<?php
$timestamp1 = mktime(23,59,59,08,12,2012);
$timestamp2 = mktime(23,59,59, 8,12,2012);

$out1 = date("m-d-Y H:i:s",$timestamp1);
$out2 = date("m-d-Y H:i:s",$timestamp2);

echo "DATE1 is : $out1\n";
echo "DATE2 is : $out2\n";

/*
output is:
DATE1 is : 12-12-2011 23:59:59 <---- IT SAYS DEC 12 2011 !!!
DATE2 is : 08-12-2012 23:59:59
*/
?>


Expected result:
----------------
DATE1 is : 08-12-2012 23:59:59
DATE2 is : 08-12-2012 23:59:59

Actual result:
--------------
DATE1 is : 12-12-2011 23:59:59
DATE2 is : 08-12-2012 23:59:59

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-06-19 10:52 UTC] derick@php.net
-Status: Open +Status: Not a bug
 [2012-06-19 10:52 UTC] derick@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Numbers starting with a 0 are octal numbers. 08 is an invalid octal number and turns into 0.
 [2012-06-19 10:59 UTC] praflo at gmail dot com
yep. sorry :(
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri May 09 21:01:27 2025 UTC