PHP Subtract seconds from datetime

If you want to subtract seconds from datetime in php. I am explaining you simply step by step how to subtract seconds from current time with PHP. you can understand a concept of how to subtract seconds from time in php. let’s see example about how to subtract seconds from time in php.
Here, I created a basic example of subtract 30 seconds from provided time in php.

<?php
  
    $time = "05:10:40";
    $newTime = date('H:i:s', strtotime($time. ' -30 seconds'));
    echo "Before Time : ".$time;
    echo "<br/>";
    echo "Updated Time : ".$newTime;
  
?>

Result:

Before Time : 05:10:40
Updated Time : 05:10:10

One thought to “PHP Subtract seconds from datetime”

Leave a Reply

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

65 − 63 =