How to Add Seconds to Time in PHP?
In this tutorial we will go over the demonstration of how to add seconds to time in php. We will look at example of php add seconds to time. you will learn add 15 seconds to time in php. i would like to share with you how to add 10 seconds to current time in php.
I will give you very simple example how to add seconds to datetime in PHP. so let's see both example with output:
Example 1: PHP Add Seconds to Time
index.php
<?php
$date = "10:10:05";
$newDate = date('H:i:s', strtotime($date. ' +10 seconds'));
echo $newDate;
?>
Output:
10:10:15
Example 2: PHP Add Seconds to Current DateTime
index.php
<?php
$newDate = date('H:i:s', strtotime('+10 seconds'));
echo $newDate;
?>
Output:
04:05:51
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.