Please tell me if the below method is reliable to check if the current date in between a range
function check_in_range($start_date, $end_date)
{
// Convert to timestamp
$start_ts = strtotime($start_date);
$end_ts = strtotime($end_date)+86400;
//added 86400 to check for that particular date too
$timeNow = strtotime("now");
// Check that user date is between start & end
return (($timeNow >= $start_ts) && ($timeNow <= $end_ts));
}
I would recommend using the date time object like so:
function check_in_range($start_date, $end_date)
{
$startDate = new \DateTime($start_date);
$endDate = new \DateTime($end_date);
$endDate->add(new \DateInterval('PT86400'));
return ((time() >= $startDate->getTimeStamp()) && (time() <= $endDate->getTimestamp()));
}