In this tutorial you will learn how to check PHP date in between two dates in a PHP web application.
PHP date in between
In this tutorial you will learn how to check PHP date in between two dates in a PHP web application. The code of "php-date-in-between.php" given below :
<?php
function is_date_between($start_date,$check_date,$end_date){
if( (strtotime($check_date)>strtotime($start_date)) &&
(strtotime($check_date)<strtotime($end_date))){
return "true";
}
return "false";
}
$start_date='1990-01-01';
$end_date='2030-01-01';
echo "check date between : ";
echo "<br>";
echo "Start date : ".$start_date;
echo "<br>";
echo "End date : ".$end_date."<br>";
$check_date=date('Y-m-d');
echo "'".$check_date."' between '".$start_date."' and '".$end_date."'";
echo " : ".is_date_between($start_date,$check_date,$end_date);
$check_date='1980-01-01';
echo "<br>";
echo "'".$check_date."' between '".$start_date."' and '".$end_date."'";
echo " : ".is_date_between($start_date,$check_date,$end_date);
?>
Output :
When run "php-date-in-between.php" display output as :


[ 0 ] Comments