Get the difference between two dates using php







Here is the code for how get the difference between two dates using php.

<?php 
$date1 = "2002-12-26";
$date2 = "2016-1-24";

$diff = abs(strtotime($date2) - strtotime($date1));
$years = floor($diff / (365*60*60*24));
$months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
$days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/(60*60*24));

printf("%d years, %d months, %d days\n", $years, $months, $days);
?>

Share With Friends

Also Read   How to disable the hyperlink on top level menu of navigation using jquery

Speak Your Mind

*

Time limit is exhausted. Please reload CAPTCHA.