Laravel 9

Get The Difference Between Two Date and Time in Minutes with Laravel?

If you have a task that should calculate the difference between two DateTime in minutes with Laravel then this could help you. In this case, we are going to use the Carbon package to calculate the difference in minutes. Carbon is already in Laravel core so nothing to worry about during the installation.

So to do this we need to define a start and end DateTime so that easier for you to understand and follow.

$start = Carbon::parse("2022-08-19 16:21:03");
$end = Carbon::parse("2022-08-19 16:28:03");

$total = $end->diffInMinutes($start);

echo $total;//Output: 7



A programmer who cares about programming matters for the web application, mobile application, and servers and their protection

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button