php check if date is in between 2 dates

[sam_ad id=”40″ codes=”true”]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

  1. Start Date
  2. End Date
  3. User Date => this should be in between Start Date and End Date

Function

Use above function as shown below

 

I hope this helps

Comments

  1. Thanks!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.