PHP Check if current date is between two dates example
In this post we will give you information about PHP Check if current date is between two dates example. Hear we will give you detail about PHP Check if current date is between two dates exampleAnd how to use it also give you demo for it if it is necessary.
In this example, i want to share with you small example of how to check current date is between startdate and enddate in php. we will check if today date is between two dates in php. we can simply check if current date is between two dates in php.
I written it very simple way so you can also use with laravel, codeigniter, zend php framework also. it’s core php code for check if date is between two dates php.
Many times we require to check current date is between given two dates or not for subscription, trial, user expire time etc. so when user will register at that time will decide when he will expire and we will check it with current date always. so might be this post can help you to check if date exists between two dates in php.
You can check bellow simple example so it can help you.
Example:
<?php
$currentDate = date('Y-m-d');
$currentDate = date('Y-m-d', strtotime($currentDate));
$startDate = date('Y-m-d', strtotime("01/09/2019"));
$endDate = date('Y-m-d', strtotime("01/10/2019"));
if (($currentDate >= $startDate) && ($currentDate
echo "Current date is between two dates";
}else{
echo "Current date is not between two dates";
}
If current date is 09/10/2019 than it will return bellow output:
Output:
Current date is between two dates
I hope it can help you…
Hope this code and post will helped you for implement PHP Check if current date is between two dates example. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs