How do you say... if inbetween these dates

Hello All:

I am trying to write a script for my job that displays a certain graphic based on a certain season or date span.

However, I cannot seem to say in the IF Statement, if between these dates.

Currently I have this:

$date = date("m.d.Y");

if ($date == "01.13.2010"){
        echo ('<tr><td align="center" valign="middle" colspan="2"><a href=""><img src="images/raffledrums_tn.jpg" border="0" hspace="0" vspace="5" width="238" height="98" alt="Giant Raffle Drums"></a></td></tr>');
    echo ('<tr><td align="center" valign="middle" colspan="2">&nbsp;</td></tr>');    

but as I soon discovered once that date is passed, tomorrow, it will not show the graphic anymore.

If anyone has any better advice for me on how to do this , that would be much appreciated,


if(time() > strtotime('24-12-2009') && time() < strtotime('25-12-2009')){
    #hey, right now, it's between 24-12-2009 00:00:00am and 25-12-2009  00:00:00am

Thanks Anthony but when I set this code you set up for me, with 08-01-2010 to 13-01-2010 it does not work.

Any thoughts on what I might be doing wrong?

You’ll need to include the time to include the day too…

if(time() > strtotime('08-01-2010 00:00:00') && time() < strtotime('13-01-2010 23:59:59')){

Time stuff is pretty messy, or at least, that’s how I find it. Failing this, check what time your server has. :slight_smile:

Thanks again Anthony,

I will have to check with my server because it is not doing what I need it too.


Looks like it might be a UK “bug”

If you format Anthony’s dates to Month, Day, Year you should be fine.

Alternatively, you can use Year-Month-Day to avoid any confusion.


I’ve had very little experience with php’s time and date functions but have you checked that your using the same date format throughout? eg in America is month/day/year and in the UK it’s day/month/year

Thanks again,

Yeah I think I got it. I am going to use all seconds because that is what seems to be working for me now on my server.