Page 1 of 1

Date specific conditional

Posted: Thu May 03, 2007 11:33 am
by seodevhead
Hey guys... Date and time related stuff is probably my biggest weakness with PHP, but I have a fairly simple problem maybe one of you can help me with.

I am making a part of a webpage that is a conditional that will do something if the current date is October of 2007 or later. So basically, I want to write some code for the page right now, so that when it does turn October, the page displays something different.

Any idea on the best way to do this? Any guidance would be greatly appreciated. Thanks.

Posted: Thu May 03, 2007 11:38 am
by mikeeeeeeey
basically it's just an if statement, with the condition being the date...

Code: Select all

if(date("F") == "October"){
  //execute code for october
}else{
  //execute code for not being october
}
hope it helps

Posted: Thu May 03, 2007 11:56 am
by seodevhead
Hey Mikeeeey... thanks for the help... but the problem I am having difficulty understanding is making the if statement like this, (in pseudo-speak below):

if (date is october 2007 or later)
{ do this }

Posted: Thu May 03, 2007 12:12 pm
by guitarlvr
Not the best at dates either but would something like this work:

Code: Select all

if((date("F") >= "October") && (date("Y") >= "2007")){
  //execute code for october 07 or >
}else{
  //execute code for not being october
}
Wayne

Posted: Thu May 03, 2007 12:17 pm
by John Cartwright

Code: Select all

if (time() > strtotime('October 2007'))
{

}

Posted: Thu May 03, 2007 1:24 pm
by seodevhead
Wow... JCart nailed it perfectly. That's genious. Thanks a bunch guys! :)