0

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.

asked May 22, 2020 at 6:23
3
  • Please add the actual code you use (which is relevant to this problem). Do you store the value of $row->getStartTime()->add - does your foreach use references for $row? Commented May 22, 2020 at 6:25
  • $row->getStartTime(); this the time object I receive. Commented May 22, 2020 at 6:29
  • I tried above mentioned 2 options but failed add add 2 seconds. Commented May 22, 2020 at 6:29

1 Answer 1

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

This is my approach, It worked.

answered May 22, 2020 at 7:08
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.