PHP Programs

Please click on 1-2 Ads to keep this website's Study Material FREE and regularly Updated.

Program 18: Write a PHP program to calculate the difference between two dates using PHP OOP approach.


<!DOCTYPE html>
	<title>PHP Progarms</title>
		$sdate = new DateTime("2000-05-27");
		$edate = new DateTime("2019-09-15");
		$interval = $sdate->diff($edate);
		echo "Difference : " . $interval->y . "years, " . $interval->m. " months, ".$interval->d." days";

If you have any suggestion or found any error in the above program, then do let us know at [email protected] or just comment below.