Re: Help with adding time

From: Date: Tue, 06 Dec 2016 08:11:15 +0000
Subject: Re: Help with adding time
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-325874@lists.php.net to get a copy of this message
You're using "H:m:s" in date(), but "m" is the month (like you used for the date in "Y-m-d"), you probably want to use "i" for 24 hours with leading zero. Cheers, Daniel On 06.12.16 16:01, Danny wrote:
Hi guys, I am trying to add 30 minutes to a Unix time stamp. Currenly the seconds are increased but not the minutes. The UNIX timestamp is echoed into a file by a BASH script for later use. Here is my code: #################################################################################### <?php $time_now = time() ; $BASH_file = fopen ( "/usr/local/bin/scripts/txt/time.txt", "r" ) ; $BASH_value = fread ( $time_file, "10" ) ; $current_time = ( date ( 'Y-m-d H:m:s', $time_now ) ) ; $endtime = ( date ( 'Y-m-d H:m:s', $BASH_value ) ) ; $target_time = date ( 'Y-m-d H:m:s', strtotime ( "+30 minutes", $BASH_value ) ) ; print ( $target_time."\n" ) ;
        if ( $current_time >= $target_time )
          {
            print ( "Time is greater\n" ) ;
          }
        else
          {
            print ( "Time is less\n" ) ;
          }
fclose ( $time_file ) ; ?> ################################################################################### Any pointers? Thank you Danny


« previous php.general (#325874) next »