php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39026 strtotime("060901") does not produce a correct date stamp for 2006-09-01
Submitted: 2006-10-03 14:57 UTC Modified: 2006-10-05 16:48 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: dbrong at gmail dot com Assigned: derick (profile)
Status: Wont fix Package: Date/time related
PHP Version: 5CVS-2006-10-03 (snap) OS: Windows 2000
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
13 + 39 = ?
Subscribe to this entry?

 
 [2006-10-03 14:57 UTC] dbrong at gmail dot com
Description:
------------
I was using date("Y-m-d", strtotime("060901")) to produce a date formatted as "2006-09-01" and this does not work anymore in the latest PHP 5 release.  It produces the actual date of the system's current time (2006-10-03 in this case).

If I modify it as strtotime("20060901") it works fine.

Reproduce code:
---------------
date("Y-m-d", strtotime("060901")) will output the current system date (2006-10-03 in this case).

Expected result:
----------------
2006-10-03 (or the current date you run the script)

Actual result:
--------------
should be 2006-09-01

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-10-05 16:07 UTC] iliaa@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

When you are using 060901 format it is not possible to tell if 
the 2nd 2 characters represent the month or the day of the 
month. In certain locales day comes first in others the month, 
the format is ambiguous. 
 [2006-10-05 16:16 UTC] iliaa@php.net
Derick thinks he can fix this :)
 [2006-10-05 16:48 UTC] derick@php.net
The "[0-9]{6}" was not properly working in PHP 4 and 5.0:

derick@tequila:~$ php-4.4dev -n -r 'echo date("Y m d H:i:s", strtotime("990104") ), "\n";'
1999 01 04 00:00:00
derick@tequila:~$ php-4.4dev -n -r 'echo date("Y m d H:i:s", strtotime("980104") ), "\n";'
1998 01 04 00:00:00
derick@tequila:~$ php-4.4dev -n -r 'echo date("Y m d H:i:s", strtotime("000104") ), "\n";'
2006 10 05 01:04:00
derick@tequila:~$ php-4.4dev -n -r 'echo date("Y m d H:i:s", strtotime("010104") ), "\n";'
2001 01 04 00:00:00
derick@tequila:~$ php-4.4dev -n -r 'echo date("Y m d H:i:s", strtotime("020104") ), "\n";'
2002 01 04 00:00:00

In PHP 5.1 and up this format is now consitently representing HHMMSS.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 15:01:30 2024 UTC