How can I convert a timestamp difference between 2 dates
$diff = abs(strtotime($date2) - strtotime($date1));
to months and days quantity as desired ouput:
$res = 4.05 //-> 4 months and 5 days
Something like this would possibly work. My maths may be a bit off.
$diff = abs(strtotime($date2) - strtotime($date1));
define('DAY',60*60*24, true);
define('MONTH',DAY*30, true);
define('YEAR',DAY*365, true);
$years = floor($diff / (YEAR));
$months = floor(($diff - $years * YEAR) / (MONTH));
$days = floor(($diff - $years * YEAR - $months*MONTH ) / (DAY));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With