PHP 4.0 Bug #6781: Error in mktime() funtion (Serious???)

From: Date: Sun, 17 Sep 2000 03:41:31 +0000
Subject: PHP 4.0 Bug #6781: Error in mktime() funtion (Serious???)
Groups: php.dev 
Request: Send a blank email to php-dev+get-33373@lists.php.net to get a copy of this message
From: landen@frg.eur.nl Operating system: Linux RH 6.0, 6.1, 6.2 PHP version: 4.0.1pl2 PHP Bug Type: *General Issues Bug description: Error in mktime() funtion (Serious???) I was using the mktime function to calculate the number of days between two dates by dividing the difference by 86400 (the number of seconds in a day) when I stumbled across this one (my code came up with fractional results): echo "2001/03/25: has ",mktime(0,0,0,3,26,2001) - mktime(0,0,0,3,25,2001)," seconds<br>"; echo "2001/03/26: has ",mktime(0,0,0,3,27,2001) - mktime(0,0,0,3,26,2001)," seconds<br>"; It seems PHP thinks the number of seconds in 2001/3/25 is 82800!!! I'm not sure if this could be a bug in a library, but it even occurs on an ancient Slackware installation. I tried the same in Perl using the POSIX module which comes up with the right answer. Now, to confuse me even more MySQL seems to have the same bug, try this: select unix_timestamp("2001/3/26") - unix_timestamp("2001/3/25"); Is it possible that you copied this bug from the MySQL code? Anyway, this could start causing big problems in date related software next year (or maybe nobody would notice)... My configure line (I don't see how php.ini could be relevant): ./configure --with-apxs=/usr/sbin/apxs --with-xml --with-pdflib --with-zlib --with-mysql=/usr --with-oracle --with-ldap

« previous php.dev (#33373) next »