<?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) } */ ?>