取数据
从数据库中取上周的数据,也就是本周取上一周的,下周取本周的,怎么取啊
------解决方案--------------------
指定日期范围就是了
------解决方案--------------------
function getLastWeekDate($date){
$iDate = strtotime($date);
$iLastDate = $iDate-7*24*60*60;
if(date('w',$iLastDate) == 0){ //周日
$sLastWeekStart = date('Y-m-d 00:00:00',$iLastDate-7*24*60*60);
$sLastWeekEnd = date('Y-m-d 23:59:59',$iLastDate);
}else{ //非周日
$sLastWeekStart = date('Y-m-d 00:00:00',$iLastDate-date('w',$iLastDate)*24*60*60);
$sLastWeekEnd = date('Y-m-d 23:59:59',$iLastDate+(7-date('w',$iLastDate))*24*60*60);
}
return array('start_time'=>$sLastWeekStart,'end_time'=>$sLastWeekEnd);
}
$arrDate = getLastWeekDate('2011-07-11 12:00:00');
var_dump($arrDate);
?>
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号