function getWeek()
{
$today = date("l"); // That's a lower case "L."
$shift = "0";
if($today == "Sunday") $shift = "-6 days";
elseif($today == "Monday") $shift = "0 days";
elseif($today == "Tuesday") $shift = "-1 day";
elseif($today == "Wednesday") $shift = "-2 days";
elseif($today == "Thursday") $shift = "-3 days";
elseif($today == "Friday") $shift = "-4 days";
elseif($today == "Saturday") $shift = "-5 days";
return date("l F j, Y", strtotime($shift, strtotime(date("l F j, Y")))); // "Ls"
}
echo getWeek();
Monday, March 5, 2007
Set "Week of" Date in PHP
As of this writing, I'm very much a PHP newbie, but here's a snippet for setting a "Week of" date where Monday is zero day and the date format is along the lines of Monday March 5, 2007.
No comments:
Post a Comment