note 96821 rejected from function.strtotime by thiago
| From: | thiago@php.net | Date: | Thu, 18 Mar 2010 02:24:12 +0000 |
| Subject: | note 96821 rejected from function.strtotime by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-167151@lists.php.net to get a copy of this message | ||
Note Submitter: arharp at gmail dot com
----
I'm running PHP 5.2.11 and I've run into issues with strtotime() interpreting MM-DD-YYYY
formatted dates differently than expected. Unless the day is above 12, it will assume that the
format of the date is DD-MM-YYYY. The easiest way to get around this is to use slashes instead of
hyphens.
<?php
echo date('Y-m-d', strtotime('01-03-2010'));
// outputs 2010-03-01
echo date('Y-m-d', strtotime('01/03/2010'));
// outputs 2010-01-03
?>
This seems like it may be a bug since the documentation states that it accepts a "US English
date format" and DD-MM-YYYY is not the standard US date format.
http://en.wikipedia.org/wiki/Calendar_date