Jump to content

[SOLVED] todays date greater than event date


busnut

Recommended Posts

G'day

 

I've got a calendar of events on one of the websites I look after, and to save remembering when events are passed and delete them after each event, I put in a couple of lines of code so that once an event has passed, it will no longer display on the website, but will still be in the database so it can be deleted when I choose, however how i've done it, it won't display the date on the specific day, instead won't show after midnight of the day of the event.

 

This is the couple of lines of code I put in, but how can I get it to be if todays date + 1 day is less than the date of the event? All i can get is if todays date is less than event date...

 

$todays_date=date(Y)."/".date(m)."/".date(d);
if ($todays_date<$date) {
and then the rest of my stuff goes in here
}

 

so somewhere in there, it needs to think that todays date is in fact tomorrow if thats the best way to do it......

 

Any help appreciated. Cheers :)

First, instead of

 

todays_date=date(Y)."/".date(m)."/".date(d);

 

use

 

todays_date=date("Y/m/d");

 

this is much faster and efficient. To get tomorrow's date:

 

todays_date=date("Y/m/d", strtotime("tomorrow"));

 

you can use it then to your condition. Hope this helps. ^^

This is weird, I got it to work, but had to do the reverse as it wasn't showing anything for today or even tomorrow using the code you gave of +1 day, so what I did was -1day and then it showed me everything that hasn't expired so to speak yet (even if the event is today).

 

So thanks for your help guys, most appreciated!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.