/**
* 月份开始结束时间戳
* $y 年
* $m 月
*/
function mFristAndLast($y = "", $m = "")
{
if ($y == "") $y = date("Y");
if ($m == "") $m = date("m");
$m = sprintf("%02d", intval($m));
$y = str_pad(intval($y), 4, "0", STR_PAD_RIGHT);
$m > 12 || $m < 1 ? $m = 1 : $m = $m;
$firstday = strtotime($y . $m . "01000000");
$firstdaystr = date("Y-m-01", $firstday);
$lastday = strtotime(date('Y-m-d 23:59:59', strtotime("$firstdaystr +1 month -1 day")));
return array(
"firstday" => $firstday,
"lastday" => $lastday
);
}
PHP获取某年某月开始和结束的时间戳
点赞
收藏