PHP 4.0 Bug #8553: mktime() report inconsistent
| From: | gherson at snet dot net | Date: | Thu, 04 Jan 2001 16:53:01 +0000 |
| Subject: | PHP 4.0 Bug #8553: mktime() report inconsistent | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-42948@lists.php.net to get a copy of this message | ||
From: gherson@snet.net
Operating system: Linux RedHat 6.2
PHP version: 4.0.4
PHP Bug Type: Date/time related
Bug description: mktime() report inconsistent
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>
EOM;
echo $msg;
// When houroffsetof1=1 and houroffsetof3=0 for mi[days]=1-400, problems occur
// from 1-86 and 297-400.
$houroffsetof1=0;
$houroffsetof3=0;
for ($i=1; $i<=4; $i++) {
$lastproblem=-99;
$forlimit=400;
echo "Testing from 1 to $forlimit with houroffsetof1=$houroffsetof1 and
houroffsetof3=$houroffsetof3:<br>";
#***FOR
for ($mi['days']=1; $mi['days']<=$forlimit; $mi['days']++) {
#***FOR
# 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) {
$houroffsetof1--;
} 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
--
Edit Bug report at: http://bugs.php.net/?id=8553&edit=1