$date = new DateTime('2021-05-18 10:15:30'); $date->add(new DateInterval('PT30S')); echo $date->format('Y-m-d H:i:s'); // Output: 2021-05-18 10:16:00
$date = date_create('2021-05-18 10:15:30'); date_add($date, date_interval_create_from_date_string('10 seconds')); echo date_format($date, 'Y-m-d H:i:s'); // Output: 2021-05-18 10:15:40In this example, we have used the date_create function to create a date object `2021-05-18 10:15:30`. We have then used the `date_add()` function which takes two parameters, the first is the date object and the second is the DateInterval object created using `date_interval_create_from_date_string()` function to specify the time interval of 10 seconds. The resulting date is `2021-05-18 10:15:40`. Both of the examples mentioned above are the default functions provided by PHP's built-in date and time functions, so no additional library or package is required for this.