Q:

Calculate the difference between two dates using PHP OOP approach

0

Calculate the difference between two dates using PHP OOP approach.

Sample Dates : 1981-11-03, 2013-09-04

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

<?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

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now