function get_last_month_last_day($date=''){
    if($date !=''){
        $time = strtotime($date);
    }else{
        $time = time();
    }

    $day = date('j',$time); //获取该日期是当月的第几天
    return date('Y-m-d',strtotime("-{$day} days",$time)); //获取当月是第几天,在减去正好是上月的最后一天
}

//测试:
echo get_last_month_last_day();
echo get_last_month_last_day('2017-11-21');

//date(format,timestamp); j - 一个月中的第几天,不带前导零(1 到 31)

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-14
  • 2022-02-05
  • 2021-06-16
  • 2022-12-23
  • 2021-12-22
  • 2021-11-29
猜你喜欢
  • 2022-12-23
  • 2021-12-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案