php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29734 Function GetDate interprets 2 different timestamps as same date
Submitted: 2004-08-18 15:17 UTC Modified: 2004-08-18 16:56 UTC
From: jlamas at gmail dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 4.3.8 OS: Linux
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: jlamas at gmail dot com
New email:
PHP Version: OS:

 

 [2004-08-18 15:17 UTC] 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.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-08-18 15:47 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.

This has something to do with DST changeover, consult http://php.net/support.php for more information.
 [2004-08-18 16:56 UTC] jlamas at gmail dot com
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 ?
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Feb 05 10:01:30 2025 UTC