-1

I have some DateTime like this 2019-10-04 07:58:00, I need the difference between the two date to be returned in minutes.

$current = strtotime(date("Y-m-d"));
$date    = strtotime(date('Y-m-d',strtotime($old_date)));
$datediff = $date - $current;

Thanks in advance.

Ahmad Karimi
  • 1,285
  • 2
  • 15
  • 26
Mukund Bharti
  • 251
  • 4
  • 19

1 Answers1

1

You can use Carbon for that:

$date1 = Carbon::parse('2019-10-04 07:01:00');
$date2 = Carbon::parse('2019-10-04 07:25:00');
echo $date2->diffInMinutes($date1);

Which here returns 24. Is that what you need?

meph
  • 209
  • 1
  • 5
  • 16