|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #8553 mktime() report inconsistent
Submitted: 2001-01-04 11:53 UTC Modified: 2001-01-04 15:02 UTC
From: gherson at snet dot net Assigned:
Status: Closed Package: Date/time related
PHP Version: 4.0.4 OS: Linux RedHat 6.2
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.
Block user comment
Status: Assign to:
Bug Type:
From: gherson at snet dot net
New email:
PHP Version: OS:


 [2001-01-04 11:53 UTC] gherson at snet dot net
Hi.  As the below script will show, I sometimes need to add an hour to  mktime()'s calculations to make its output consistent with other mktime() output.  In the below loop that tests 400 days, the hour offset is needed for days 87 - 296.

$msg = <<<EOM
1. Determination of an exp date's number of days from 1/1/2001. <br>
Algorithm: (exp date's timestamp - 1/1/2001's timestamp) / # of seconds in a day.<br><br>
3. Determination of today's number of days from 1/1/2001.<br>
Algorithm: (today's timestamp - 1/1/2001's timestamp) / # of seconds in a day.<br>
echo $msg;

// When houroffsetof1=1 and houroffsetof3=0 for mi[days]=1-400, problems occur 
// from 1-86 and 297-400.
for ($i=1; $i<=4; $i++) {
echo "Testing from 1 to $forlimit with houroffsetof1=$houroffsetof1 and houroffsetof3=$houroffsetof3:<br>"; 
for ($mi['days']=1; $mi['days']<=$forlimit; $mi['days']++) {

# 1.
$expTStamp = mktime(date("G")+$houroffsetof1,date("i"),date("s"),date("m"),date("d")+$mi['days'],date("y"));
$exp_daysFrom2001 = ($expTStamp - 978325200) / 86400; 

# 2.  (Currently unused 1/4/01)
$test = mktime(1,0,0,1,1+$mi['days'],2001);
$exponly_daysFrom2001 = ($test - 978325200) / 86400; 
#echo "2. exponly_daysFrom2001=$exponly_daysFrom2001  Should equal mi['days'].<br>";

# 3.
$test = mktime(date("G")+$houroffsetof3,date("i"),date("s"),date("m"),date("d"),date("y"));
$today_daysFrom2001 = ($test - 978325200) / 86400; 

if ($exp_daysFrom2001 != ($mi['days'] + $today_daysFrom2001)) {
   if ($lastproblem +1 == ($mi['days']) ) {
      echo " and at {$mi['days']}";
   } else {
  		echo "<br>";
      echo "lastproblem=$lastproblem<br>";
		echo "1 != (mi[days] + 3) mismatch problem at mi['days']={$mi['days']}<br>";
		echo "1. exp_daysFrom2001=$exp_daysFrom2001<br>";  
		echo "3. today_daysFrom2001=$today_daysFrom2001<br>"; 
	} // end if last iteration was problem.
   $lastproblem = $mi['days'];
} // end if problem
} //end for 1 - mi[days]
echo "<br><br>";
if ($houroffsetof1==0) {
	$houroffsetof1 = 1;
} elseif ($houroffsetof3==0) {
   if ($houroffsetof1==1) {
   } else {
   	$houroffsetof1 = 1;
	$houroffsetof3 = 1;
} // end if $houroffset
} //end for i=1-4

phpinfo() reports my configure line as:                                         './configure' '--with-cybercash=/home/httpd/html/paysmartnet-16/mck-cgi'
'--with-pgsql=/var/lib/pgsql' '--with-apxs', which is correct except for the cybercash directory. (No, i didn't move it after the configure or the compile, which i did as carefully as i could.  I don't know why phpinfo has it wrong, except that an old configure did reference that directory once.  I did remember to delete the config.cache between configures.)

I don't think my php.ini is relevant due to my light customization.

My setup is not unusual in any way i know of.  Pentium II, 350Mhz, 128MB ram.

I didn't configure with --enable-debug, so I can't offer a gdb  backtrace, sorry.

Thank you,
George Herson
Pls feel free to call me 8am - 11pm EST: 203-324-4981


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-01-04 15:02 UTC]
Rasmus added:

Congratulations, you've discovered Daylight Savings Time.

So closing...
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jun 19 06:01:30 2024 UTC