php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30663 strtotime not decrementing minutes correctly
Submitted: 2004-11-02 16:26 UTC Modified: 2004-11-02 16:32 UTC
From: alistair at maclean-nj dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.0.2 OS: Linux (RH9)
Private report: No CVE-ID: None
 [2004-11-02 16:26 UTC] 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



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-11-02 16:32 UTC] derick@php.net
Duplicate of bug #30042
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Thu Oct 08 10:00:01 2026 UTC