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. Here is an example of how to add 30 seconds to the current time:

<?php

$time = time();
$new_time = strtotime("+30 seconds", $time);
echo "Original time: " . date("Y-m-d H:i:s", $time) . "\n";
echo "New time: " . date("Y-m-d H:i:s", $new_time) . "\n";

This will output something like:

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

Watch a course Learn object oriented PHP

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

<?php

$date = new DateTime();
$date->modify('+30 seconds');
echo $date->format('Y-m-d H:i:s');

This will output something like:

2021-01-26 08:48:04