/**
* 獲取同比上月的日期
* 沒有的取上月最後一天
* @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;
}