Strongly recommended book
Hi Guys,
Thought I should share this with you.
I had a problem where I had to check if a date exists between a given date range.
I searched PHP API and did not find a suitable out of the box function which can assist me with this problem so I thought to write one.
Here is what my approach was
So we got three dates
- Start Date
- End Date
- User Date => this should be in between Start Date and End Date
Function
function isDateInRange($startDate, $endDate, $userDate) { return (($userT >= $startT) && ($userT <= $endT));
Use above function as shown below
echo isDateInRange('2011-12-01','2011-12-31','2011-12-30'); // above will result in true echo isDateInRange('2011-12-01','2011-12-31','2012-02-20'); // above will result in false
I hope this helps
Link to this article is below
Search Terms:
- date range in php
- range between dates in php
- php check if date
- if date in range date php
- php - how to check if a date is in a given range?
- php search between date user order
- php test if date








Recent Comments