In this tutorial, you will learn how to check the current date is between two dates in PHP. In the example, I will pick the current date and will check with the other two dates to check. In our application development, many times we require to check the current date is between the start date and end date. Let's demonstrate this using example.

Example:

<?php
   
$current_date = date('Y-m-d'); //Current date was 17-11-2019
$current_date = date('Y-m-d', strtotime($current_date));
   
$start_date = date('Y-m-d', strtotime("05/02/2019"));
$end_date = date('Y-m-d', strtotime("10/03/2020"));
   
if (($current_date >= $start_date) && ($current_date <= $end_date)){
    echo "Current date is between two dates";
}else{
    echo "Current date is not between two dates";  
}

Output:

Current date is between two dates

using strtotime() we converted the date into the proper date format.

Written by
Check out this Author's contributed articles.
If you like Tutorialsmint and would like to contribute, you can also write an article using Write an Article. See your article appearing on the Tutorialsmint main page and help other programmers to enhance their knowledge.

Comments(0)

RECENT TUTORIALS
Wed Dec 26 • 08:00 AM GMT
Wed Dec 26 • 08:00 AM GMT
Wed Dec 26 • 08:00 AM GMT
Wed Dec 26 • 08:00 AM GMT
Wed Dec 26 • 08:00 AM GMT
Edit Post
Add Reply