// 上个月的时间戳
    $thismonth = date('m');
    $thisyear = date('Y');
    if ($thismonth == 1) {
        $lastmonth = 12;
        $lastyear = $thisyear - 1;
    } else {
        $lastmonth = $thismonth - 1;
        $lastyear = $thisyear;
    }

    $lastStartDay = $lastyear . '-' . $lastmonth . '-1';
    $lastEndDay = $lastyear . '-' . $lastmonth . '-' . date('t', strtotime($lastStartDay));
    $b_time = strtotime($lastStartDay);//上个月的月初时间戳
    $e_time = strtotime($lastEndDay);//上个月的月末时间戳

// 下个月的时间戳
    $thismonth = date('m');
    $thisyear = date('Y');
    if ($thismonth == 12) {
        $lastmonth = 1;
        $lastyear = $thisyear + 1;
    } else {
        $lastmonth = $thismonth + 1;
        $lastyear = $thisyear;
    }
    $lastStartDay = $lastyear . '-' . $lastmonth . '-1';
    $lastEndDay = $lastyear . '-' . $lastmonth . '-' . date('t', strtotime($lastStartDay));
    
    $b_time = strtotime($lastStartDay);//下个月的月初时间戳
    $e_time = strtotime($lastEndDay);//下个月的月末时间戳

亲测有效

 

相关文章:

  • 2022-12-23
  • 2021-06-19
  • 2022-12-23
  • 2021-10-01
  • 2022-01-23
  • 2021-11-29
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-20
  • 2022-12-23
  • 2022-12-23
  • 2021-10-03
  • 2021-12-12
相关资源
相似解决方案