-1

I have the following code

$time = "12:00";
$duration = 90 . " minutes";
$arrival = strtotime("+" . $duration, $time);

Output should be 13:30.

I get the following error: "A non well formed numeric value encountered in" (line with $arrival)

What can I do?

Sharanya Dutta
  • 3,981
  • 2
  • 17
  • 27
stefana
  • 2,606
  • 3
  • 29
  • 47

3 Answers3

3

The following code should work:

$time = strtotime("12:00");
$duration = "+90 minutes";
$arrival = strtotime($duration, $time);
print(date("H:i", $arrival));

Demo: https://eval.in/95328

Read more about Unix timestamp and the PHP function strtotime.

Sharanya Dutta
  • 3,981
  • 2
  • 17
  • 27
1

Consider using PHP DateTime and DateInterval classes, like this:

$time = new \DateTime('now');
$time->add( new \DateInterval('PT90M') );
rafaame
  • 822
  • 2
  • 12
  • 22
1

Try This Simple code :

<?php $time = strtotime('12:00');
$more = date("H:i", strtotime('+90 minutes', $time)); ?>
Priya jain
  • 753
  • 2
  • 5
  • 15