php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30357 Date function returns incorrect results
Submitted: 2004-10-08 06:35 UTC Modified: 2004-10-08 08:56 UTC
From: vidya at webwisesage dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 4.3.8 OS: Unix
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: vidya at webwisesage dot com
New email:
PHP Version: OS:

 

 [2004-10-08 06:35 UTC] vidya at webwisesage dot com
Description:
------------
I wrote a little program below that shows the problem.  This simply adds 1 day to the date and prints the date.

At Oct 31st, 2004, it prints 2004-10-31 TWICE.  In other words, the date function is returning an incorrect result.

Reproduce code:
---------------
<?php
define("ONEDAY",86400);    //  seconds in a day

$startdate = "20041001";
$timestamp = strtotime($startdate); 
for($i=0; $i<95; $i++):
  $timestamp = $timestamp + ONEDAY; 
  $workingdate = date("Y-m-d",$timestamp);
  echo("NEXT DAY IS  $workingdate <br>");
endfor;
?>

Expected result:
----------------
All dates from 10-02-2004 until 01-02-2005 printed one after the other in sequence.

Actual result:
--------------
NEXT DAY IS 2004-10-26 
NEXT DAY IS 2004-10-27 
NEXT DAY IS 2004-10-28 
NEXT DAY IS 2004-10-29 
NEXT DAY IS 2004-10-30 
NEXT DAY IS 2004-10-31 
NEXT DAY IS 2004-10-31 
NEXT DAY IS 2004-11-01 
NEXT DAY IS 2004-11-02 
NEXT DAY IS 2004-11-03 
NEXT DAY IS 2004-11-04 
NEXT DAY IS 2004-11-05 


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-10-08 06:41 UTC] gschlossnagle@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

congratulations, you\'ve discovered daylight savings 
time!
 [2004-10-08 08:56 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.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 12 13:01:33 2025 UTC