-2

I am developing a web app using PHP (Codeigniter). When a user makes a request for a certain resource in the app I need to check if todays date is before or after the 25th of this month. How can I do this? I do not know how to do it.

Ben Everard
  • 13,652
  • 14
  • 67
  • 96
Jonathan Clark
  • 19,726
  • 29
  • 111
  • 175
  • There've been A LOT of questions about PHP dates. If you google it, you will get answer in first 2 pages. – Robik May 08 '12 at 11:17
  • @Donut haters gonna hate, this site is for helping not hating – Petah May 08 '12 at 11:21
  • @Petah This site is not for duplicates. http://stackoverflow.com/faq#close – Robik May 08 '12 at 11:22
  • @Donut, then close vote, and point out duplicates, don't hate. – Petah May 08 '12 at 11:25
  • Similar questions: http://stackoverflow.com/questions/4149569/php-checking-if-the-current-date-is-before-or-after-a-set-date http://stackoverflow.com/questions/8475019/php-check-if-current-time-is-before-specified-time – Robik May 08 '12 at 11:28

2 Answers2

3

This should do it...

if ( date('j') < 25 ) {
    // date before 25th
}
Ben Everard
  • 13,652
  • 14
  • 67
  • 96
2

You can use the date function with the j format type for that

if (date('j') > 25) {
    // It is after the 25th
} elseif (date('j') < 25) {
    // It is before the 25th
} else {
    // It is the 25th
}

See http://php.net/manual/en/function.date.php for more info

Petah
  • 45,477
  • 28
  • 157
  • 213