It seems unsafe to rely on strtotime to handle ordinary dates - at least in PHP versions <5.3. (I tested with 5.2.9 and 5.2.11 and none of them worked, despite the requirement in the online documentation that the error was fixed in 5.2.7.)
Adding "from", as suggested, apparently only works in php 5.3+, and generally speaking, bypassing the ordinal will return the "first" event, but other ordinals will be for 7 days.
The best solution for PHP 5.2 is something like this:
$recurrOrdinal = "last"; $dayOfWeek = "Thursday"; $monthYear = "March 2011"; echo ordinalDate($recurrOrdinal, $dayOfWeek, $monthYear); function ordinalDate($recurrOrdinal, $dayOfWeek, $monthYear) { $firstDate = date("j", strtotime($dayOfWeek . " " . $monthYear) ); if ($recurrOrdinal == "first") $computed = $firstDate; elseif ($recurrOrdinal == "second") $computed = $firstDate + 7; elseif ($recurrOrdinal == "third") $computed = $firstDate + 14; elseif ($recurrOrdinal == "fourth") $computed = $firstDate + 21; elseif ($recurrOrdinal == "last") { if ( ($firstDate + 28) <= date("t", strtotime($monthYear)) ) $computed = $firstDate + 28; else $computed = $firstDate + 21; } return date("Ymd", strtotime($computed . " " . $monthYear) ); }
source share