php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27737 mktime() has problems with DST
Submitted: 2004-03-27 14:40 UTC Modified: 2004-03-28 11:26 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: m dot konings at knowmany dot nl Assigned:
Status: Closed Package: Date/time related
PHP Version: 4.3.5 OS: Windows
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: m dot konings at knowmany dot nl
New email:
PHP Version: OS:

 

 [2004-03-27 14:40 UTC] m dot konings at knowmany dot nl
Description:
------------
When iterating through a date value, day by day, I use the following code a lot:

$cur_date = mktime(0, 0, 0, date('m', $cur_date), date('d', $cur_date)+1, date('Y', $cur_date));

This used to work perfectly on PHP 4.3.4. But with 4.3.5 this call keeps returning 27-3-2004 as soon as it hits this date. I guest this has something to do with Daylight Saving Time. When you change to call to:

$cur_date = mktime(1, 0, 0, date('m', $cur_date), date('d', $cur_date)+1, date('Y', $cur_date));

It actually works fine, so it turns out that 00:00:00 @ 28-3-2004 is treated as 27-3-2004.


Reproduce code:
---------------
<?
$cur_date = mktime(0, 0, 0, 3, 1, 2004);
while($dummy++ < 31) {
	echo date('d-m-Y', $cur_date)."<br>\n";
	$cur_date = mktime(0, 0, 0, date('m', $cur_date), date('d', $cur_date)+1, date('Y', $cur_date));	
}

Expected result:
----------------
I expected to see the next list (as it worked on 4.3.4):

20-03-2004
21-03-2004
22-03-2004
23-03-2004
24-03-2004
25-03-2004
26-03-2004
27-03-2004
28-03-2004
29-03-2004


Actual result:
--------------
But I actually saw this:

20-03-2004
21-03-2004
22-03-2004
23-03-2004
24-03-2004
25-03-2004
26-03-2004
27-03-2004
27-03-2004
27-03-2004

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-03-27 16:30 UTC] m dot konings at knowmany dot nl
The Windows STABLE CVS snapshot does not have this problem! Does this mean it will be solved (automatically) in a next version?
 [2004-03-27 16:34 UTC] derick@php.net
We did some fixes regarding this problem, but we're not totally sure if the current fix is always correct. Please test PHP4.3.6RC1 when it's out (takes a couple of weeks) to see if it still works for you after we made the other changes.
 [2004-03-28 11:26 UTC] rasmus@php.net
An easy workaround in the meantime is to avoid using midnight as your time for your iteration.  Use noon instead and you should never have any DST-related issues.
 [2004-07-13 15:10 UTC] www dot carlos at bol dot com dot br
eu quero comprar meus jogadores e participar de qualquerb campeonato que tiver copas campeonatos ligas e tudo mais.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Sep 12 15:00:01 2025 UTC