You are here: Strtotime() / date() Bug in PHP - all versions « All PHP « IT news, forums, messages
Strtotime() / date() Bug in PHP - all versions

Posted by Michael J Martin on 03/29/06 19:47

I've found a biggie in PHP this week and need to report it to the
appropriate people but don't know how to, does anyone know how to report it?

Essentially the bug's in either strtotime or date. Consider the following:
$tdate = date("y_m_d", strtotime("last Sunday"));

Well this week (27 March starting), PHP reported 'last Sunday' as being
25 March 2006. 'last Sunday' is actually 26 March 2006. What makes it
even more interesting is that if I did:
$tdate = date("y_m_d", strtotime("last Sunday 10am"));

PHP correctly reports that it's the 26 March 2006.

I think it's something to do with the Daylight time saving. But
nonetheless it's still a bug because PHP should take this into account
as 'last Sunday' was definitely the 26 March 2006.

As far as I can tell, all versions are affected, I've tested it on PHP
4.3.10 (http://www.westminster-abbey.org/phpinfo.php) and 5.0.5
(http://mike-martin.com/phpinfo.php) scroll to bottom for bug demonstration.

Here's some code if anyone wants to test for themselves:

phpinfo();
print ("<h3>Date: " . date("y_m_d", strtotime("today")) . "</h3>\n");
print ("<h4>Last Sunday: " . date("y_m_d", strtotime("last Sunday")) .
"</h4>\n");
print ("<h4>Last Sunday 10AM: " . date("y_m_d", strtotime("last Sunday
10am")) . "</h4>\n");

Any thoughts / help in reporting the bug would be much appreciated.

Regards,

Mike Martin
Managing Director
gobisoft Ltd.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация