您的位置:首页 > 编程语言 > PHP开发

php 得到 上/下/当前 星期几的时间的函数

2013-12-16 10:18 344 查看
//得到下个周2的时间:get_next_of_the_week(2);
function get_next_of_the_week($oftheweek){
$today = date('w');
$today = $today == 0 ? 7 : $today;
$date =	strtotime( date('Y-m-d', strtotime( '+'. (7 + $oftheweek - $today) .' days' )) );
return $date;
}


//得到上个周3的时间:get_prev_of_the_week(3);
function get_prev_of_the_week($oftheweek){
$today = date('w');
$today = $today == 0 ? 7 : $today;
$date =	strtotime( date('Y-m-d', strtotime( '-'. (7 - $oftheweek + $today) .' days' )) );
return $date;
}


//得到这个星期5的时间: get_current_of_the_week(5);
function get_current_of_the_week($oftheweek){
$today = date('w');
$today = $today == 0 ? 7 : $today;
$date =	strtotime( date('Y-m-d', strtotime( '-'. ($today - $oftheweek) .' days' )) );
return $date;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: