php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51613 Ugly Error in date() and strtotime()
Submitted: 2010-04-20 11:22 UTC Modified: 2010-04-20 11:24 UTC
From: contact at vladrotariu dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.3.2 OS: Ubuntu 9.10
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: contact at vladrotariu dot com
New email:
PHP Version: OS:

 

 [2010-04-20 11:22 UTC] contact at vladrotariu dot com
Description:
------------
When you try to create a succession of months using the following code, you will notice a very ugly bug that results in skipping months

Test script:
---------------
for(
				$i = strtotime("2004-10-01" );
				$i <= mktime();
				$i += (24*60*60 * cal_days_in_month( CAL_GREGORIAN, date("m", $i), date("Y", $i) ))
			) {
				$year_month = date("Ymd H:i:s", $i);
				echo "<br />".$year_month;
			}

Expected result:
----------------
20041001 00:00:00
20041101 00:00:00
20041201 00:00:00

Actual result:
--------------
20041001 00:00:00
20041031 23:00:00
20041201 23:00:00

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-04-20 11:24 UTC] aharvey@php.net
-Status: Open +Status: Bogus
 [2010-04-20 11:24 UTC] aharvey@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.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 06:01:34 2025 UTC