Php code to find the 2nd wed of each month

software development


i host a meeting on the 2nd wed of every month, and rather than change the date on my main page every month manually (currently stored in a text file), i was wondering if someone could help me with some code to do it automatically.

many thanks,



You can get a lot of useful tips about time, date etc from


I decided to mess with this just to see what was involved. It wasn’t that complicated but it took more steps than I originally anticipated. Someone else could probably find a more efficient way but since no one suggested a solution, try this:

Output looks like this: Wednesday, March 11, 2009

<?php $mon = date("m"); $year = date("y"); // find the first weds of this month which will be within 7 days for ($dayofmonth=1; $dayofmonth<=7; $dayofmonth++) { $dateArr = getdate(mktime(0, 0, 0, $mon, $dayofmonth, $year)); if ( !strcmp($dateArr["weekday"], "Wednesday") ) { // advance to following wednesday $dayofmonth += 7; break; } } $secWeds = date("l, F d, Y", mktime(0, 0, 0, $mon, $dayofmonth, $year)); print($secWeds); ?>