php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49011 Middle Endian date format only semi-recognized by strtotime
Submitted: 2009-07-21 21:06 UTC Modified: 2009-07-21 21:21 UTC
From: soapergem at gmail dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.3.0 OS: Windows
Private report: No CVE-ID: None
 [2009-07-21 21:06 UTC] soapergem at gmail dot com
Description:
------------
An extremely common date format in the USA is middle endian, which is often expressed in one of two ways. Today's date (July 21, 2009) could be expressed as either of the following:

1. 07/21/2009
2. 07-21-2009

Currently, if the first version (1) is passed into strtotime(), it successfully parses the date. However, the second version (2) returns FALSE.

Reproduce code:
---------------
<?php

var_dump(strtotime('07/21/2009')); // good
var_dump(strtotime('07-21-2009')); // bad

?>

Expected result:
----------------
int(1248152400)
int(1248152400)

Actual result:
--------------
int(1248152400)
bool(false)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-07-21 21:21 UTC] derick@php.net
This is a design decision. If you use / (the prefered US way), it uses MM/DD/YYYY and if you use - (the preferred UK way), it uses DD-MM-YYYY. If you want to parse the MM-DD-YYYY format, have a look at http://uk2.php.net/manual/en/datetime.createfromformat.php (beware though, the format it uses is only *resembling* that what date() supports. The docs are vague here).
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 13 21:01:33 2025 UTC