Calculate the difference between two dates
Copy this code and paste it in your HTML
$date1 = "2008-03-15";
$date2 = "2011-03-16";
$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);
Report this snippet
Comments
Subscribe to comments