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
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: 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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Fri Jun 14 23:01:29 2024 UTC