1

I am using this code to generate time difference

$to_time = strtotime("2017-03-13 10:42:00");
$from_time = strtotime("2017-03-13 10:21:00");
echo round(abs($to_time - $from_time) / 60,2). " minute";

It was working fine but when my from_time is 23:44:00 and to time is 00:44:00 I am getting time difference -1380 minute.

Please help me on this.

Reference article of stackoverflow link

Community
  • 1
  • 1

1 Answers1

0

The problem is:-

It seems that You are calculating difference only on the basis of time.

But when date will also consider then problem will not occur because 23:44:00 will be considered as next date with 00:44:00 time (automatically by php strtotime) and calculation will be accurate.

Check here:-https://eval.in/752519

Alive to die - Anant
  • 70,531
  • 10
  • 51
  • 98