#51081 [Opn->Asn]: date("g:ia",strtotime("24:00")) returns 1:00am
| From: | degeberg@php.net | Date: | Thu, 18 Feb 2010 14:20:50 +0000 |
| Subject: | #51081 [Opn->Asn]: date("g:ia",strtotime("24:00")) returns 1:00am | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-3936@lists.php.net to get a copy of this message | ||
ID: 51081
Updated by: degeberg@php.net
Reported By: mike dot turpin at gmail dot com
-Status: Open
+Status: Assigned
-Bug Type: Date/time related
+Bug Type: Documentation problem
Operating System: Windows Vista
PHP Version: 5.2.12
-Assigned To:
+Assigned To: degeberg
Previous Comments:
------------------------------------------------------------------------
[2010-02-18 14:16:31] mike dot turpin at gmail dot com
I did originally point out the problem as a suspected documentation
bug. Could the documentation point out this?
------------------------------------------------------------------------
[2010-02-18 14:14:28] mike dot turpin at gmail dot com
-Status: Bogus
+Status: Open
Just to point out that I actually found this in version 5.2.11 but
don't want to upgrade yet as my web host uses this version.
------------------------------------------------------------------------
[2010-02-18 14:14:11] derick@php.net
-Status: Open
+Status: Bogus
This is not a bug, the following happens in 5.2:
strtotime( "24:00" ) returns "false" (because 24:00 is not supported)
date() uses an integer representation of false (0) and then formats it
using the current timezone:
php -r 'echo date(DateTime::ISO8601 . " e", 0), "\n";'
1970-01-01T01:00:00+0100 Europe/London
(Yes, on Jan 1st 1970, London had an offset of UTC+1, search for
"British Standard Time Act 1968 (1968 c. 45)" at
http://www.srcf.ucam.org/~jsm28/british-time/)
In PHP 5,3, "24:00" is supported and the following happens:
derick@kossu:~$ php -r 'echo strtotime("24:00");'
1266537600
derick@kossu:~$ php -r 'echo date(DateTime::ISO8601 . " e",
1266537600), "\n";'
2010-02-19T00:00:00+0000 Europe/London
------------------------------------------------------------------------
[2010-02-18 14:02:10] degeberg@php.net
-Bug Type: Documentation problem
+Bug Type: Date/time related
Seems to be a bug in the 5.2 branch. Reclassifying.
====================
daniel@daniel-laptop:~$ php -r 'echo
phpversion().PHP_EOL.date("g:ia",strtotime("24:00")).PHP_EOL;'
5.3.1
12:00am
daniel@daniel-laptop:~$ ~/src/php-5.2.12/sapi/cli/php -r 'echo
phpversion().PHP_EOL.date("g:ia",strtotime("24:00")).PHP_EOL;'
5.2.12
1:00am
====================
------------------------------------------------------------------------
[2010-02-18 13:47:03] mike dot turpin at gmail dot com
Description:
------------
I suspect that this is a documentation problem in strtotime rather than
a bug, but I think it should be pointed out in the doc as it's easy to
fall into the trap.
strtotime("24:00") returns false
If you then have:
date("g:ia",strtotime("24:00"))
You will get 1:00am but might be expecting 12:00am
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=51081&edit=1