php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68492 Function strtotime() returns wrong values for some dates
Submitted: 2014-11-24 11:46 UTC Modified: 2014-11-24 13:23 UTC
From: anwendungsentwickler at gmail dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.5.19 OS: Windows 7
Private report: No CVE-ID: None
 [2014-11-24 11:46 UTC] anwendungsentwickler at gmail dot com
Description:
------------
The function strtotime returns in some cases wrong values - regarding to the test script:

Returns:
24.06.08  : 2014-11-25
24.06.2008: 2008-06-24
----------------------
25.06.08  : 2008-06-25
25.06.2008: 2008-06-25


Expected:
24.06.08  : 2008-06-24
24.06.2008: 2008-06-24
----------------------
25.06.08  : 2008-06-25
25.06.2008: 2008-06-25

Tested on:
5.5.11 WIN
5.5.15 WIN
5.2.17 Linux

Test script:
---------------
<pre><?php
echo "PHP VERSION: ".PHP_VERSION."\n";
for($i = 1; $i <= 30; ++$i) {
    $day = str_pad($i, 2, '0', STR_PAD_LEFT);
    $dateTwo = "$day.06.08";
    $dateFour = "$day.06.2008";
    echo $dateTwo."  : ".date("Y-m-d", strtotime($dateTwo));
    echo "\n";
    echo $dateFour.": ". date("Y-m-d", strtotime($dateFour));
    echo "\n".str_repeat('-', 22)."\n";
}



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-11-24 13:23 UTC] derick@php.net
-Status: Open +Status: Not a bug
 [2014-11-24 13:23 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

"24.06.08" is interpreted as 24h 06m 08s, and because there is no hour 25, that specific rule fails and it falls back to 25d 06m 2008y.

Run:

var_dump(date_parse('24.06.08'));

to see it for yourself.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 22:00:01 2026 UTC