php统计时间段,周,年,月,日

标准
/*$time = time (); //判断当天是星期几,0表星期天,1表星期一,6表星期六 $w_day = date ( "w", $time ); //php处理当前星期时间点上,根据当天是否为星期一区别对待 if ($w_day == '1') { $cflag = '+0'; $lflag = '-1'; } else { $cflag = '-1'; $lflag = '-2'; } //本周一零点的时间戳 $start_time = strtotime ( date ( 'Y-m-d', strtotime ( "$cflag week Monday", $time ) ) ); //本周末零点的时间戳 $stop_time = strtotime ( date ( 'Y-m-d', strtotime ( "$cflag week Monday", $time ) ) ) + 7 * 24 * 3600; foreach ( $userlist as $key => $value ) { $rmap ['endtime'] = array ('gt', $start_time ); $rmap ['endtime'] = array ('lt', $stop_time ); $smap ['ruid'] = $userlist [$key] ['uid']; } echo "今天:".date("Y-m-d")."<br>"; echo "昨天:".date("Y-m-d",strtotime("-1 day")), "<br>"; echo "明天:".date("Y-m-d",strtotime("+1 day")). "<br>"; echo "一周后:".date("Y-m-d",strtotime("+1 week")). "<br>"; echo "一周零两天四小时两秒后:".date("Y-m-d G:H:s",strtotime("+1 week 2 days 4 hours 2 seconds")). "<br>"; echo "下个星期四:".date("Y-m-d",strtotime("next Thursday")). "<br>"; echo "上个周一:".date("Y-m-d",strtotime("last Monday"))."<br>"; echo "一个月前:".date("Y-m-d",strtotime("last month"))."<br>"; echo "一个月后:".date("Y-m-d",strtotime("+1 month"))."<br>"; echo "十年后:".date("Y-m-d",strtotime("+10 year"))."<br>"; * */

发表评论