W3docs

Add 30 seconds to the time with PHP

You can use the strtotime function in PHP to add a specified number of seconds to a given time.

You can use the strtotime function in PHP to add a specified number of seconds to a given time. Here is an example of how to add 30 seconds to the current time:

Example of using the strtotime function in PHP to add a specified number of seconds to a given time

php— editable, runs on the server

This will output something like:


Original time: 2021-01-26 08:47:34
New time: 2021-01-26 08:48:04

You can also use date_modify() function of DateTime class to achieve the same thing :

Example of using date_modify() function of DateTime class in PHP to add a specified number of seconds to a given time

php— editable, runs on the server

This will output something like:


2021-01-26 08:48:04