#30357 [Bgs]: Date function returns incorrect results
| From: | derick@php.net | Date: | Fri, 08 Oct 2004 06:56:49 +0000 |
| Subject: | #30357 [Bgs]: Date function returns incorrect results | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-67268@lists.php.net to get a copy of this message | ||
ID: 30357
Updated by: derick@php.net
Reported By: vidya at webwisesage dot com
Status: Bogus
Bug Type: Date/time related
Operating System: Unix
PHP Version: 4.3.8
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2004-10-08 06:41:04] 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 06:35:18] 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
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=30357&edit=1