From:             arpad at rajeczy dot com
Operating system: Windows XP
PHP version:      5.1.0RC1
PHP Bug Type:     Date/time related
Bug description:  strtotime() fails with 1-12am/pm

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 bug report at http://bugs.php.net/?id=34771&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=34771&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=34771&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=34771&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=34771&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=34771&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=34771&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=34771&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=34771&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=34771&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=34771&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=34771&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=34771&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=34771&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=34771&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=34771&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=34771&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=34771&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=34771&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=34771&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=34771&r=mysqlcfg

Reply via email to