#29734 [Bgs]: Function GetDate interprets 2 different timestamps as same date
| From: | jlamas at gmail dot com | Date: | Wed, 18 Aug 2004 14:56:38 +0000 |
| Subject: | #29734 [Bgs]: Function GetDate interprets 2 different timestamps as same date | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-64855@lists.php.net to get a copy of this message | ||
ID: 29734
User updated by: jlamas at gmail dot com
Reported By: jlamas at gmail dot com
Status: Bogus
Bug Type: Date/time related
Operating System: Linux
PHP Version: 4.3.8
New Comment:
I´ve changed what you said and the error continues.
The error occurs on this line:
'$sDataLoop = getdate($nTimeStamp);'
The date and mktime functions generate the dates correctly. I debugged
this code and it generates the date 2004-10-18. But when the getdate
function read the timestamp generated by the strtotime function it
reads 2004-10-17.
Does it have another function similar to getdate ?
Previous Comments:
------------------------------------------------------------------------
[2004-08-18 15:47:07] 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.
This has something to do with DST changeover, consult
http://php.net/support.php for more information.
------------------------------------------------------------------------
[2004-08-18 15:17:59] jlamas at gmail dot com
Description:
------------
The function GetDate interprets the both timestamps as October 17th,
2004.
The timestamps are: 1097895600 and 1097978400
Reproduce code:
---------------
$tbDataInicial = '2004-10-01';
$tbDataFinal_temp = '2004-10-31';
while ($sDataLoop != $tbDataFinal_temp)
{
if ($sDataLoop == "")
{$sDataLoop=$tbDataInicial;}
//Add one more day
$nTimeStamp=strtotime($sDataLoop);
$sDataLoop = getdate($nTimeStamp);
$sDataLoop=date("Y-m-d",mktime(0,0,0,$sDataLoop['mon'],$sDataLoop['mday']+1,$sDataLoop['year']));
}
Expected result:
----------------
The while should go through the parameters $tbDataInicial and
$tbDataFinal that represents the begin and end dates respectively.
Actual result:
--------------
This generates and infinite loop since $sDataLoop get stucked on the
day October 17th, 2004.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=29734&edit=1