#34771 [Fbk->Asn]: strtotime() fails with 1-12am/pm
| From: | derick@php.net | Date: | Fri, 07 Oct 2005 07:34:07 +0000 |
| Subject: | #34771 [Fbk->Asn]: strtotime() fails with 1-12am/pm | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-86171@lists.php.net to get a copy of this message | ||
ID: 34771
Updated by: derick@php.net
Reported By: arpad at rajeczy dot com
-Status: Feedback
+Status: Assigned
Bug Type: Date/time related
Operating System: Windows XP
PHP Version: 5.1.0RC1
-Assigned To:
+Assigned To: derick
Previous Comments:
------------------------------------------------------------------------
[2005-10-07 09:21:22] sniper@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php5-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5-win32-latest.zip
------------------------------------------------------------------------
[2005-10-07 04:30:52] arpad at rajeczy dot com
Description:
------------
strtotime() now returns false for input like '12am', where the minutes
are omitted with am, pm, a.m. or p.m.
This should be allowed according to the GNU date input formats:
http://www.gnu.org/software/tar/manual/html_chapter/tar_7.html#SEC112
It works correctly in 4.3.10, 4.4.0 and 5.0.4.
It fails in 5.1.0RC1, built Aug 16 2005 13:49:49 and 5.1.0RC2-dev,
built Oct 6 2005 20:17:56.
Reproduce code:
---------------
<pre><?php
$tests = array(
'12am', '1am', '1pm',
'12a.m.', '1a.m.', '1p.m.',
'12:00am', '1:00am', '1:00pm',
'12:00a.m.', '1:00a.m.', '1:00p.m.'
);
foreach ($tests as $test) {
$t = strtotime($test);
printf("%-10s => %-15s => %s\n", $test, var_export($t, 1),
date('r', $t));
}
?></pre>
Expected result:
----------------
12am => 1128643200 => Fri, 07 Oct 2005 00:00:00 +0000
1am => 1128646800 => Fri, 07 Oct 2005 01:00:00 +0000
1pm => 1128690000 => Fri, 07 Oct 2005 13:00:00 +0000
12a.m. => 1128643200 => Fri, 07 Oct 2005 00:00:00 +0000
1a.m. => 1128646800 => Fri, 07 Oct 2005 01:00:00 +0000
1p.m. => 1128690000 => Fri, 07 Oct 2005 13:00:00 +0000
12:00am => 1128643200 => Fri, 07 Oct 2005 00:00:00 +0000
1:00am => 1128646800 => Fri, 07 Oct 2005 01:00:00 +0000
1:00pm => 1128690000 => Fri, 07 Oct 2005 13:00:00 +0000
12:00a.m. => 1128643200 => Fri, 07 Oct 2005 00:00:00 +0000
1:00a.m. => 1128646800 => Fri, 07 Oct 2005 01:00:00 +0000
1:00p.m. => 1128690000 => Fri, 07 Oct 2005 13:00:00 +0000
Actual result:
--------------
12am => false => Thu, 01 Jan 1970 00:00:00 +0000
1am => false => Thu, 01 Jan 1970 00:00:00 +0000
1pm => false => Thu, 01 Jan 1970 00:00:00 +0000
12a.m. => false => Thu, 01 Jan 1970 00:00:00 +0000
1a.m. => false => Thu, 01 Jan 1970 00:00:00 +0000
1p.m. => false => Thu, 01 Jan 1970 00:00:00 +0000
12:00am => 1128643200 => Fri, 07 Oct 2005 00:00:00 +0000
1:00am => 1128646800 => Fri, 07 Oct 2005 01:00:00 +0000
1:00pm => 1128690000 => Fri, 07 Oct 2005 13:00:00 +0000
12:00a.m. => 1128643200 => Fri, 07 Oct 2005 00:00:00 +0000
1:00a.m. => 1128646800 => Fri, 07 Oct 2005 01:00:00 +0000
1:00p.m. => 1128690000 => Fri, 07 Oct 2005 13:00:00 +0000
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=34771&edit=1