#30663 [Opn->Bgs]: strtotime not decrementing minutes correctly

From: Date: Tue, 02 Nov 2004 15:32:47 +0000
Subject: #30663 [Opn->Bgs]: strtotime not decrementing minutes correctly
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-68635@lists.php.net to get a copy of this message
ID: 30663 Updated by: derick@php.net Reported By: alistair at maclean-nj dot com -Status: Open +Status: Bogus Bug Type: Date/time related Operating System: Linux (RH9) PHP Version: 5.0.2 New Comment: Duplicate of bug #30042 Previous Comments: ------------------------------------------------------------------------ [2004-11-02 16:26:48] alistair at maclean-nj dot com Description: ------------ Trying to subtract 1 minute from a time string, using the strtotime() function. Under PHP 4.x the function works. Under 5.0.2 and the php5-STABLE-200411021330 CVS version the function does not work as advertised. The compile file is : ./configure --with-apxs2=/usr/local/apache2/bin/apxs --enable-force-cgi-redirect --disable-debug --disable-rpath --enable-inline-optimization --with-openssl --with-xml --with-zlib --with-layout=REDHAT --enable-magic-quotes --enable-safe-mode --enable-sockets --enable-sysvsem --enable-sysvshm --enable-discard-path --enable-track-vars --enable-trans-sid --enable-wddx --without-oci8 --with-pear=/usr/share/pear --with-mysql=shared,/usr --with-mysqli=/usr/bin/mysql_config --with-soap The php.ini file is standard except that the include path has been enabled to include the pear directory (/usr/share/pear) and a number of search paths (like ../objects:../../objects), and the extension=mysql.so is made. Reproduce code: --------------- <?php function ModifyEndTime($endtime) { $first_iter = strtotime($endtime); // 1 // Remove that minute! $second_iter = strtotime( "-1 minute", $first_iter); // 2 // $second_iter = strtotime( "-1 minute", $endtime); // 3 $newtime = date('H:i:s',$second_iter); echo "Entry time was : {$endtime} processed time is : {$newtime}\n"; } ModifyEndTime("07:01:00"); ModifyEndTime("07:00:00"); ?> Expected result: ---------------- Entry time was : 07:01:00 processed time is : 07:00:00 Entry time was : 07:00:00 processed time is : 06:59:00 As produced by running on PHP 4.3.8 Actual result: -------------- Entry time was : 07:01:00 processed time is : 23:59:00 Entry time was : 07:00:00 processed time is : 23:59:00 if lines with ending comments 1 & 2 are commented out and line with ending comment 3 is used instead (only running through strtotime() once) the the following is produced: Entry time was : 07:01:00 processed time is : 18:59:59 Entry time was : 07:00:00 processed time is : 18:59:59 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=30663&edit=1

« previous php.bugs (#68635) next »