Compare two dates in php


<pre>
	<?php 
	$date = "2021-12-25";
	$today = date("Y-m-d");
	$today_time = strtotime($today);
	$compare_date = strtotime($date);
	if($compare_date > $today_time){
		echo 'Future date';
	}else{
		echo 'Past Date';
	}
	?>
</pre>

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s