busnut Posted March 22, 2009 Share Posted March 22, 2009 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 Link to comment https://forums.phpfreaks.com/topic/150633-solved-todays-date-greater-than-event-date/ Share on other sites More sharing options...
bluejay002 Posted March 23, 2009 Share Posted March 23, 2009 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. ^^ Link to comment https://forums.phpfreaks.com/topic/150633-solved-todays-date-greater-than-event-date/#findComment-791381 Share on other sites More sharing options...
busnut Posted March 23, 2009 Author Share Posted March 23, 2009 Thanks bluejay002 for the more efficient code - I didn't know that little trick, so thats helpful, but with the last bit of code you posted, it still won't display any events that happen/end today. Link to comment https://forums.phpfreaks.com/topic/150633-solved-todays-date-greater-than-event-date/#findComment-791445 Share on other sites More sharing options...
redarrow Posted March 23, 2009 Share Posted March 23, 2009 <?php $todays_date=date("Y/m/d", strtotime("+ 1 DAY")); echo $todays_date; ?> this code works <?php $todays_date=date("Y/m/d", strtotime("tomorrow")); echo $todays_date; ?> Link to comment https://forums.phpfreaks.com/topic/150633-solved-todays-date-greater-than-event-date/#findComment-791460 Share on other sites More sharing options...
busnut Posted March 23, 2009 Author Share Posted March 23, 2009 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! Link to comment https://forums.phpfreaks.com/topic/150633-solved-todays-date-greater-than-event-date/#findComment-791482 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.