根据所给的某一天的日期获取该日期前一天的时间的封装的方法:
function getYesterday($date){
if(empty($date)){
$yesterday = date("Y-m-d",strtotime("-1 day"));
}else{
$arr = explode(‘-‘, $date);
$year = $arr[0];
$month = $arr[1];
$day = $arr[2];
$unixtime = mktime(0,0,0,$month,$day,$year)-86400;
$yesterday = date(‘Y-m-d‘,$unixtime);
}
return $yesterday;
}
时间: 2024-11-02 06:19:52