Bansaw Posted November 19, 2010 Share Posted November 19, 2010 What is the easiest way of finding out in php what date a certain day falls on? ie: I want to know what date is the 3rd Thursday of every month. for example, this month would be " The third Thursday of this month falls on : 18th November " Whats the best way of doing that in php? Thanks,, Quote Link to comment Share on other sites More sharing options...
jmace Posted November 19, 2010 Share Posted November 19, 2010 You might try the date() function along with the mktime() function. Something like this: echo date("D", mktime(0, 0, 0, date('m'), date('d')+7, date('Y'))); //show next weeks day I would first figure out what day today is, then how many more day's till thursday, then start displaying the answer with code like the above. Sorry I don't have time to post more, but later if you still need help let me know. Quote Link to comment Share on other sites More sharing options...
Bansaw Posted November 19, 2010 Author Share Posted November 19, 2010 thanks, thats helpful. My website has an event on the 3rd Thursday of every month. So I want to code something that runs once a day and updates the website. I think my logic could go something like this: 1) Find out what current month is 2) Find out what date the 3rd Thursday falls on in our current month 3) If current date <= 3rdThursday_of_current_month then display "Be ready, our next event is Thursday 18th November" Else If current date > 3rdThursday_of _current_month display "Be ready, our next event is Thursday 16th December" Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted November 19, 2010 Share Posted November 19, 2010 Depends on how you want to start it: $date = strtotime('last day last month'); $date = strtotime('+3 thursday', $date); echo date('jS F', $date); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.