i have used this function in my project.it seems works well :-)
code:
function get_monday_and_sunday_of_lastweek($str_date = "")
{
$mas = array();
if(empty($str_date)) $str_date = strtotime(date('Y-m-d'));
else $str_date = strtotime($str_date);
if(!$str_date)
{
return $mas;
}
if(date('w',$str_date) == 1)
{
$mas['last_monday'] = date('Y-m-d',strtotime('last Monday',$str_date));
}
else
{
$mas['last_monday'] = date('Y-m-d',strtotime('last Monday',strtotime('last Monday',$str_date)));
}
$mas['last_sunday'] = date('Y-m-d',strtotime('last Sunday',$str_date));
return $mas;
}
function get_monday_and_sunday_of_thisweek($str_date)
{
$mas = array();
if(empty($str_date)) $str_date = strtotime(date('Y-m-d'));
else $str_date = strtotime($str_date);
if(!$str_date)
{
return $mas;
}
if(date('w',$str_date) == 1)
{
$mas['monday'] = date('Y-m-d',$str_date);
}
else
{
$mas['monday'] = date('Y-m-d',strtotime('last Monday',$str_date));
}
if(date('w',$str_date) == 0)
{
$mas['sunday'] = date('Y-m-d',$str_date);
}
else
{
$mas['sunday'] = date('Y-m-d',strtotime('next Sunday',$str_date));
}
return $mas;
}
?>
3/25/2009
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment