#49011 [Opn->Bgs]: Middle Endian date format only semi-recognized by strtotime
| From: | derick@php.net | Date: | Tue, 21 Jul 2009 21:21:57 +0000 |
| Subject: | #49011 [Opn->Bgs]: Middle Endian date format only semi-recognized by strtotime | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-140036@lists.php.net to get a copy of this message | ||
ID: 49011
Updated by: derick@php.net
Reported By: soapergem at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: Date/time related
Operating System: Windows
PHP Version: 5.3.0
New Comment:
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).
Previous Comments:
------------------------------------------------------------------------
[2009-07-21 21:06:22] 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)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=49011&edit=1