How to subtract minutes from current time in PHP

How to subtract minutes from current time in PHP

 

// Get Current Time in PHP (Here your time in Hour:Minutes:Seconds Format)

$cur_time = date("h:i:s");

// Now convert the time to string using strtotime function

$timetostr = strtotime( $cur_time );

// Next we want to subtract 20 minutes in the current time

$my_newtime = $timetostr - ( 20*60 ); // here 20 is minute & 60 is second, Because 1 Minute = 60 Seconds

// Print your subtracted time

$final_time = date("h:i:s",$my_newtime);

echo $final_time;

Cheers.

Leave a Reply

Your email address will not be published. Required fields are marked *