How To Check Current Date Between Two Dates In Php?

Hi guys,

In this artical, I will show you how to check current date between two dates in php. current date between two date check in using php.

You can check date between two dates using php .You can get current date then start date and end date between date then return true otherwise false return.

Solution 1
<?php
$today = date('Y-m-d');
$today=date('Y-m-d', strtotime($today));

$stratDate = date('Y-m-d', strtotime("01/01/2018"));
$endDate = date('Y-m-d', strtotime("01/12/2019"));

if (($today >= $stratDate) && ($today <= $endDate)){
    echo "true";
}else{
    echo "false";  
}

If return true you current date in between two dates, return false not between in two date


Solution 2
<?php
$stratDate = date('Y-m-d', strtotime("01/01/2018"));
$endDate = date('Y-m-d', strtotime("01/12/2019"));

if ((date('Y-m-d', time()) >= $stratDate) && (date('Y-m-d', time()) <= $endDate)){
    echo "true";
}else{
    echo "false";  
}

If return true you current date in between two dates, return false not between in two date

It will help you...