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.

date_diff.php

<!DOCTYPE html>
<html>
<head>
	<title>PHP Progarms TutorialDuniya.com</title>
</head>
<body>
	<?php
		$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";
	?>
</body>
</html>



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.