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

From: Date: Sun, 17 Sep 2000 05:50:22 +0000
Subject: PHP 4.0 Bug #6781 Updated: Error in mktime() funtion (Serious???)
Groups: php.dev 
Request: Send a blank email to php-dev+get-33371@lists.php.net to get a copy of this message
ID: 6781 User Update by: landen@frg.eur.nl Status: Open Bug Type: Date/time related Description: Error in mktime() funtion (Serious???) Previous Comments: --------------------------------------------------------------------------- [2000-09-16 23:41:31] landen@frg.eur.nl 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 --------------------------------------------------------------------------- Full Bug description available at: http://bugs.php.net/?id=6781

« previous php.dev (#33371) next »