获取某一时间戳的月份的开始时间戳和结束时间戳

<?php
function getMonthStartAndEnd($timestamp){
    $startTime = strtotime(date("Y-m-01 00:00:00",$timestamp));
    $startTimeStr = date("Y-m-d H:i:s",$startTime);
    $endTime = strtotime("+1 month -1 sec",$startTime);
    return [$startTime,$endTime];
}

?>
<?php
var_dump(getMonthStartAndEnd(1640851462));
/**输出:

array(2) {
  [0]=>
  int(1638288000)
  [1]=>
  int(1640966399)
}
*/
?>
原文地址:https://www.cnblogs.com/felixwan/p/15749306.html