PHP Subtract Seconds from Time Example
This article will provide some of the most important example php subtract seconds from datetime. i explained simply step by step php subtract seconds from current time. you can understand a concept of how to subtract seconds from time in php. let’s discuss about how to subtract seconds from current time in php. Here, Creating a basic example of subtract 10 seconds from current time in php.
I will give you very simple example how to sub seconds to date and time in PHP. so let's see both example with output:
Example 1: PHP Subtract Seconds to DateTime
index.php
<?php
$date = "10:10:50";
$newDate = date('H:i:s', strtotime($date. ' -10 seconds'));
echo $newDate;
?>
Output:
10:10:40
Example 2: PHP Subtract Seconds to Current DateTime
index.php
<?php
$newDate = date('H:i:s', strtotime(' -10 seconds'));
echo $newDate;
?>
Output:
06:39:23
i hope it can help you...
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- How to Subtract Hours from DateTime in PHP?
- How to Add Seconds to Time in PHP?
- PHP Add Minutes to Time Example
- PHP Add Hours to Datetime Example
- PHP Subtract Year from Date Example
- PHP Subtract Month from Date Example
- How to Subtract Days to Date in PHP?
- How to Add Months to Date in PHP?
- How to Add Days to Date in PHP?