Thursday, September 28, 2006

end of week function for the previous week

I needed a PHP function that would give the date for the end of the week for the previous week.
Here's what i came up with.

function endofweek(){

$thisdate = date('Y-m-d');
$dayofweek = date('w', strtotime($thisdate));
$sunday = date('Y-m-d', strtotime("-$dayofweek days"));
return $sunday;

}

Leave a comment if you find this useful. :)

No comments: