PHP Date Object Add 3 Seconds

62 Views Asked by At

I want to add 2 seconds for current date object, I am getting data objects as propel foreach array result, this is the object I receive

DateTime Object
    (
        [date] => 2020-05-22 09:03:21.000000
        [timezone_type] => 3
        [timezone] => Australia/Melbourne
    )

I tried this ways but no any change,

$row->getStartTime()->add(DateInterval::createFromDateString('+2 seconds'));

$row->getStartTime()->add(new DateInterval('PT2S'));

But I am unable to get the new with 2 seconds added for received time.

1

There are 1 best solutions below

0
user2552863 On
$time = $row->getStartTime()->format('H:i:s'); 
$callTimeMax = date('H:i:s', strtotime('+3 seconds', strtotime($time)));

This is my approach, It worked.