First Friday script updated and simplified
This is an update to the previous post found here: http://www.web-geek.net/posts/2008/10/20/calculate-the-first-friday-of-next-month-with-php/
With this update I have drastically reduced and simpified the code to produce the same results. I did some rigorous testing of my own to make sure this script will calculate the correct date, but that doesn’t mean it’s bullet-proof. If you find a bug, please email me so I can fix it.
first-friday.php
<?php // first-friday.php v0.1.3 by, Chris Kankiewicz <http://www.web-geek.net> // Calculate next Friday for ($x = date('d'); $x <= (date('d') + 6); $x++) { $timeStamp = mktime(0,0,0,date('m'),$x,date('Y')); if (date('w',$timeStamp) == 5) { $nextFriday = mktime(0,0,0,date('m'),$x,date('Y')); } } // Check if next Friday is the first friday of the month. if (date('d', $nextFriday) <= 7) { $firstFriday = $nextFriday; } else { // Calculate first Friday of next month for ($x = 1; $x <= 7; $x++) { $timeStamp = mktime(0,0,0,date('m')+1,$x,date('Y')); if (date('w',$timeStamp) == 5) { $firstFriday = mktime(0,0,0,date('m')+1,$x,date('Y')); } } } // Echo next first Friday echo date("F j, Y", $firstFriday); ?>

