Find second Saturday bug?

I have the following php routine that is supposed to find the second saturday in june of any given year


$month = 6;   // should always be june
$year = date("Y");
echo '<br>Show Date: ' . date('F',strtotime('Second Saturday '.date('F o', @mktime(0,0,0, $month, 1, $year))));
echo ' ' . date('j',strtotime('Second Saturday '.date('F o', @mktime(0,0,0, $month, 1, $year))));
echo ', ' . date('Y',strtotime('Second Saturday '.date('F o', @mktime(0,0,0, $month, 1, $year)))) ;	
echo '<br>';
//

However, while testing, I add one to the year ($year = date(“Y”) + 1;) and it shows the 15th of June, 2013. But the second saturday is the 8th since the 1st in 2013 is the 1st saturday. How to fix this???

E

You should be able to do this:


$year = date("Y");
$secondSaturday = strtotime('+1 week sat june ' + $year);

Attribution: I adapted this from this thread over on SO. I knew there was a way to do it, but I had forgotten the syntax…googling did the rest.