IMB IMB - 1 year ago 80
PHP Question

Find date_diff in minutes?


be used to compute difference in minutes?

$a = date_create('2016-11-03 00:00:00');
$b = date_create('2016-11-05 00:19:00');

$dd = date_diff($a, $b);
echo $dd->format('%i');

The above code will return
19 minutes
even if it's already been
2 days

Answer Source

Try this

it will output difference in minutes.

$a = new DateTime('2016-11-05 00:00:00');
$b = new DateTime('2016-11-05 00:19:00');
 $diff =  ($b->getTimestamp() - $a->getTimestamp())/60;
 echo $diff;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download