How to check current date between two dates in PHP ?

Share Me
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

Hello Dev’s,
Now today in this article, I will teach you how to check current date between two dates in php application. So current date between two date check in by using php.

Now you can check date between two dates by using php .So you can get current date then you have start date and also end date if between date then it return true otherwise it false return.

Solution 1

$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";  
}

It will return true if your current date in between two dates, and it return false if not between in two date

Solution 2

$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";  
}

It will return true if your current date in between two dates, and it return false if not between in two date

Read Also : How to check current Date between Two Date in Carbon Laravel 8?

Thanks for read. I hope it help you. For more you can follow us on facebook

About Shahriar Sagor

My name is Shahriar sagor. I'm a developer. I live in Bangladesh and I love to write tutorials and tips that will help to other Developer's. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by Shahriar Sagor →