Bug #71802 [NEW]: strtotime parses "13:01 PM" as 16:01
| From: | php at richardneill dot org | Date: | Fri, 11 Mar 2016 17:15:03 +0000 |
| Subject: | Bug #71802 [NEW]: strtotime parses "13:01 PM" as 16:01 | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-199760@lists.php.net to get a copy of this message | ||
From: php at richardneill dot org
Operating system: Linux
PHP version: 5.6.19
Package: Date/time related
Bug Type: Bug
Bug description:strtotime parses "13:01 PM" as 16:01
Description:
------------
The time expression "13:01 P.M." is technically malformed (it's
tautologous), but people are still likely to use it sometimes. PHP
mis-converts it, turning 13 into 16 !.
(In comparison, the Unix date command rejects it)
Test script:
---------------
PHP:
<?
echo date ("Y-m-d H:i:s", strtotime("13:01 P.M."));
#result: 2016-03-11 16:01:00
#expected: 2016-03-11 13:01:00
echo date ("Y-m-d H:i:s", strtotime("12:01 P.M."));
#result: 2016-03-11 12:01:00
#correct
?>
Shell:
$ date -d '13:01 P.M.';
date: invalid date â13:01 P.M.â
$ date -d '12:01 P.M.';
Fri Mar 11 12:01:00 GMT 2016
Expected result:
----------------
PHP shouldn't be off-by-3.
--
Edit bug report at https://bugs.php.net/bug.php?id=71802&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=71802&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=71802&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=71802&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=71802&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=71802&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=71802&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=71802&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=71802&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=71802&r=support
Expected behavior: https://bugs.php.net/fix.php?id=71802&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=71802&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=71802&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=71802&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=71802&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=71802&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=71802&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=71802&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=71802&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=71802&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=71802&r=mysqlcfg