php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39311 mktime() doesn't work after 28 October 2006
Submitted: 2006-10-30 16:42 UTC Modified: 2006-10-30 16:59 UTC
From: xg_wahyu at yahoo dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.1.6 OS: Windows XP
Private report: No CVE-ID: None
 [2006-10-30 16:42 UTC] xg_wahyu at yahoo dot com
Description:
------------
I run such script on my webserver Apache 2.0 running PHP 5.1.6
Before the date 28 October 2006 inclusive, everything works fine. On the 29 October, the result does not yield string "29 October 2006" and after 29 October 2006 the script simply crashes the server (the task manager indicates 50% CPU time on apache.exe from my pentium 4 HT processor for 30 seconds before timeout)

Halloween Egg? (not easter egg)?

Reproduce code:
---------------
$now = mktime(0,0,0,date('m'),date('d'),date('Y'));
$first = mktime(0,0,0,10,1,2006);
$diff = ($now - $first)/86400 + 1;
for ($i=$diff;$i>0;$i--) {
	$a = strtotime("-$i day");
	$today = getdate("$a");
	$month_format = $today['mon'];
	$day_format = $today['mday'];
	$year_format = $today['year'];
	echo "$month_format/$day_format/$year_format<br />";
}

Expected result:
----------------
Anything ranging from the date 9/30/2006 up to the current date set on the server clock

Actual result:
--------------
//date:27 october 2006 (correct)
...
10/25/2006
10/26/2006
10/27/2006

//date:28 october 2006 (correct)
...
10/25/2006
10/26/2006
10/27/2006
10/28/2006

//date:29 october 2006 (simply '10/29/2006' missing)
...
10/25/2006
10/26/2006
10/27/2006
10/28/2006

//date:30 october 2006 and so on (simply crashes the system and returns...
"Fatal error: Maximum execution time of 30 seconds exceeded in D:\php\toko\ntz.php on line 15")

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-10-30 16:59 UTC] derick@php.net
We are happy to tell you that you just discovered Daylight Savings
Time. For more information see:
http://webexhibits.org/daylightsaving/b.html
Instead of using mktime/date consider using gmmktime and gmdate which do
not suffer from DST.

Your code is broken, not all days have 86400 seconds... (when DST changes f.e.)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 05 08:01:30 2024 UTC