Calculate the difference between two dates using PHP OOP approach.
Sample Dates : 1981-11-03, 2013-09-04
<?php $sdate = new DateTime("1981-11-03"); $edate = new DateTime("2013-09-04"); $interval = $sdate->diff($edate); echo "Difference : " . $interval->y . " years, " . $interval->m." months, ".$interval->d." days "; ?>
Sample Output:
Difference : 31 years, 10 months, 1 days
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer