Stumped by Third Day of Month problem


Posted on 16th Feb 2014 07:03 pm by admin

I am trying to build an algorithm that will essentially do this:
Code: [Select]$this_month = October
$third_sunday = CalculateThirdSunday(October)

if ( ( TodaysDate before $third_sunday ) | ( TodaysDate == $third_sunday )
do something
else CalculateThirdSunday(November)
do something else

So the sorta pseudo-code above should reveal that I want a function that will always take the current month and calculate the third Sunday. Then if it's on or before that third sunday do something. However if it is after the the third Sunday, then we will calculate the third sunday of next month and then do something.

I can calculate what the third sunday out from now() is quite trivially:

<?PHP echo date('l jS F (Y-m-d)', strtotime('third Sunday')); ?>

But anyone got any idea how to find the third sunday from the beginning of the month? I tried something like

<?PHP echo date('l jS F (Y-m-d)', strtotime('2009-10-01 +third Sunday')); ?>

but that appears to not work. It tells me the next sunday is in Feb

No comments posted yet

Your Answer:

Login to answer
175 Like 11 Dislike
Previous forums Next forums
Other forums

Registration
ok so i have a site where people can register and login which works now thanks to someone on here th

apart from cron
I need to run a php file every one hour. Is there any other solution apart from cron job?

Retail terminologys not been altered after activing Retail System
Hi, All

After I active Retail System via TCode SWF5, the terms does not been changed, th

mr8m - reverse document
Friends,

I'm trying to reverse a document held by MIRO, but it reports the message balan

This is driving me nuts!
This insert query looks to be alright, however I get this error:

QuoteYou have an error in yo

COde for a Cc
I'm not receiving $ft as a Cc. Why is that??

$to = "$email";
$headers = "Fr

whats wrong with my code please help!!!
this is the error


Warning: mysql_close(): supplied argument is not a valid MySQL-Link res

Changes to hosting company's server has affected web contact form
I started a thread a couple of months ago about the contact forms on my client's website. Basically

get url?
how do i get the url of the page i'm currently on, on my website.. i think its get header.. how do i

Need help making a script that moves data into acrhive table
Hi,

I'm kinda new to php/mysql

And i wrote a simple script to store sales lead for a b

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash