How to check if current date is between two dates in PHP?

In this post, we can simply check if current date is between two dates in php.

1. Code:

<?php
function checkCurrentDateBetweenTwoDate($startDate, $endDate){
    $currentDate = date('Y-m-d');
	$currentDate = date('Y-m-d', strtotime($currentDate));
	$startDate = date('Y-m-d', strtotime($startDate));
	$endDate = date('Y-m-d', strtotime($endDate));
	if (($currentDate >= $startDate) && ($currentDate <= $endDate)){
             return "Current date is between two dates";
	}else{
             return "Current date is not between two dates";  
        }
} 

$startDate = "09/09/2022";
$endDate = "10/10/2022";
   echo(checkCurrentDateBetweenTwoDate($startDate, $endDate));
?>

2. Example:

Input:

$startDate = "09/09/2022";
$endDate = "10/10/2022";

Output:

"Current date is between two dates