(1)PHP獲得指定日期所在星期的第一天和最後一天,具體代碼如下:
function getdays($day){
$lastday=date('Y-m-d',strtotime("$day Sunday"));
$firstday=date('Y-m-d',strtotime("$lastday -6 days"));
return array($firstday,$lastday);
}print_r(getdays('2012-06-2'));
(2)PHP獲得指定日期所在月的第一天和最後一天
*function getdays($day){
$firstday = date('Y-m-01',strtotime($day));
$lastday = date('Y-m-d',strtotime("$firstday +1 month -1 day"));
return array($firstday,$lastday);
}
print_r(getdays('2015-01-28'));