Jump to content

newb - how to easily find out what date a day falls on...?


Bansaw

Recommended Posts

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,,

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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"

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.