/**
* 获取同比上月的日期
* 没有的取上月最后一天
* @param $date
* @return string
*/
function getTongBiDate($date){
$time = strtotime($date);
$start_date = date('Y-m-d', strtotime('-1 month', strtotime(date('Y-m', $time))));
// 上个月的天数
$lm_days = date('t', strtotime($start_date));
//本月查的日期
$day = date('d', $time);
if($lm_days < $day){
$tb_date = date('Y-m', strtotime($start_date))."-".$lm_days;
}else{
$tb_date = date('Y-m-d', strtotime('-1 month', $time));
}
return $tb_date;
}
获取同比上月的日期 没有取上月最后一天
猜你喜欢
转载自blog.csdn.net/sosemseo/article/details/105725412
今日推荐
周排行