From: [EMAIL PROTECTED]
Operating system: Linux 2.4.2
PHP version: 4.0.4pl1
PHP Bug Type: Date/time related
Bug description: strtotime() cannot properly handle some ISO 8601-compliant strings
I've recently run into a problem. This problem has been addressed in bug report
#9007, but I thought I would try to provide more detailed information.
First, I'm pulling ISO 8601-compliant date strings from a PostgreSQL 7.0.3.
We'll illustrate this bug with a sample date: 1999-06-24 00:01:00-05. Or June 24,
1999, 12:01 AM CDT.
$timestamp = "1999-06-24 00:01:00-05";
$timestamp = strtotime($timestamp);
print(strftime("%A, %B %d, %Y %H:%M %Z", $timestamp));
Now, that output /should/ read "Thursday, June 24, 1999 00:01 CDT," instead it reads
"Wednesday, June 23, 1999 19:06 CDT." Even though PHP knows the timezone of the
machine to be CST6CDT, it subtracts 5 hours from the time during conversion,
regardless.
This is a Bad Thing(tm) because all programs should be ISO 8601-compliant. Currently
PHP4 is a lil' broken. This should be fixed in the next release of PHP4, IMHO. The
bug probably actually resides in the code in ext/standard/parsedate.c that is borrowed
from GNU Bison 1.28. So maybe this bug should be reported to GNU's bug list as well.
In any case, here's a fix in the meantime...
If using PostgreSQL issue the command "SET DATESTYLE TO Postgres;" in all of your
queries that return a timestamp. That will cause the timestamp to be returned in this
style: Thu Jun 24 00:01:00 1999 CDT. This style will correctly parse, as we will
illustrate with this example:
$timestamp = "Thu Jun 24 00:01:00 1999 CDT";
$timestamp = strtotime($timestamp);
print(strftime("%A, %B %d, %Y %H:%M %Z", $timestamp));
The output of this example is "Thursday, June 24, 1999 00:01 CDT," which is correct.
And that's all.
Derek P. Moore
[EMAIL PROTECTED]
--
Edit Bug report at: http://bugs.php.net/?id=9640&edit=1
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]