PHP code to get number of days between two dates

Right now we are taking two dates and getting their disparities, the following code can be utilized to get precise date distinction in days between two dates.

Source Code and Output to get a number of days between two dates:

	function dateDiff($date1, $date2) 
	  $date1_ts = strtotime($date1);
	  $date2_ts = strtotime($date2);
	  $diff = $date2_ts - $date1_ts;
	  return round($diff / 86400);
	$dateDiff= dateDiff($date1, $date2);
	printf("Difference between in two dates : " .$dateDiff. " Days ");
	print "</br>";


Difference between in two dates : 5 Days

Leave a Comment

error: Alert: Content is protected!!