天天看点

php获取自然周自然月,周几,月,周第一天,最后一天总结

echo

"第几个月:"

;

echo

date

(

'n'

);

echo

"本周周几:"

;

echo

date

(

"w"

);

echo

"本月天数:"

;

echo

date

(

"t"

);

//本周一

$start=date("Y-m-d",strtotime("now Monday"));      
//本周日      
echo date("Y-m-d",strtotime("$start.+6 day"));
//上一周的周一周末        
$start=date("Y-m-d",strtotime("2016-11-07"."-1 week Monday"));      
echo date("Y-m-d",strtotime("$start.+6 day"));
//下一周的周一周末      
$start=date("Y-m-d",strtotime("2016-11-07"."+1 week Monday"));         
echo date("Y-m-d",strtotime("$start.+6 day"));        
//本月的第一天,最后一天          
$start=date('Y-m-01', strtotime(date("Y-m-d")));         
echo date('Y-m-d', strtotime("$start +1 month -1 day"));      
//上一个月的第一天,最后一天      
$start=date("Y-m-d",strtotime("2016-11-01"."-1 month"));        
echo date('Y-m-d', strtotime("$start +1 month -1 day"));         
//下一个月的第一天,最后一天      
$start=date("Y-m-d",strtotime("2016-11-01"."+1 month"));        
echo date('Y-m-d', strtotime("$start +1 month -1 day"));