Do you want to calculate the difference between two days in php? I mean the difference between two days in days, months, years using php. if yes than that i will show you php you get a difference between two days using strtotime(), abs() and floor().

We may sometimes need to find the differences between the php of your application, even if you use any php framework like laravel, codeigniter, wordpress but you can use php code anywhere. So you can see the following examples. Bellow examples will help you calculate the difference between two days in php example.

Example

<?php
  
$start_date = "2020-05-20";
$end_date = "2020-08-27";
  
$diff_data = abs(strtotime($end_date ) - strtotime($start_date ));
   
$years_diff = floor($diff_data / (365*60*60*24));
print_r("Years:".$years_diff );
   
$months_diff = floor(($diff_data - $years_diff * 365*60*60*24) / (30*60*60*24));
print_r(" Months:".$months_diff);
   
$days_diff = floor(($diff_data - $years_diff * 365*60*60*24 - $months_diff*30*60*60*24)/ (60*60*24));
print_r(" Days:".$days_diff );
?>