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)

Did you know?Explore Trending and Topic pages for more stories like this.
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

PHP - MySQL Fail
My PHP code will only execute the first part of my code...

Code: <?php

sessio

validating url
im trying to validate url's sent to me by a form
the url's im collecting are for placing banners

php require help needed
Ok i tried to use the search funtion but the word require is everywhere.

i'm really new to cr

WM transfer order: confirm different batch than proposed by system
Hi folks,

following scenario: we have a full WM with mixed batch numbers allowed in stora

Required to login help
I'm trying to set up my site so users have to be logged into the forum to access the site.I've been

I need an iframe that calls up a different page according to the date
hi

I don't know any php (only html) and I urgently need to do the following:

I need a

ECC6 - Single sign-on
We are in the process of upgrading to ECC 6 which will support single sign on with user passwords al

I apologise! It's a newbie to PHP feedback form problem!
Hi,

I am a total newbie to PHP. I am also a unemployed and need to get a job. So after 100% r

understanding functions and classes
Code: [Select]
class person {
var $name = "Jimmy Goe";

function get_nam

Any Good MMORPGs you've played?
I'm about to have ALOT of free time on my hands (finished highschool) and I need something to fill t

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