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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Mon May 20 15:01:36 2024 UTC