#30663 [NEW]: strtotime not decrementing minutes correctly
| From: | alistair at maclean-nj dot com | Date: | Tue, 02 Nov 2004 15:26:54 +0000 |
| Subject: | #30663 [NEW]: strtotime not decrementing minutes correctly | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-68634@lists.php.net to get a copy of this message | ||
From: alistair at maclean-nj dot com
Operating system: Linux (RH9)
PHP version: 5.0.2
PHP Bug Type: Date/time related
Bug description: strtotime not decrementing minutes correctly
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 bug report at http://bugs.php.net/?id=30663&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=30663&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=30663&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=30663&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=30663&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=30663&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=30663&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=30663&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=30663&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=30663&r=support
Expected behavior: http://bugs.php.net/fix.php?id=30663&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=30663&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=30663&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=30663&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=30663&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=30663&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=30663&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=30663&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=30663&r=float
MySQL Configuration Error: http://bugs.php.net/fix.php?id=30663&r=mysqlcfg