美文网首页
php根据指定年月份获取月初月末的时间戳

php根据指定年月份获取月初月末的时间戳

作者: 配角_2763 | 来源:发表于2019-01-03 11:43 被阅读0次

function get_ctime($month){

        $month_start =strtotime($month) ;//指定年月份月初时间戳

        $BeginDate=date('Y-m-01', strtotime($month));

        $EndDate = date('Y-m-d', strtotime("$BeginDate +1 month -1 day"));

        $month_end= strtotime("next day", strtotime($EndDate)) - 1;//指定年月份月末时间戳

        $months=$month_start .' and '.$month_end;

        return $months;

}

$month = "2018-12";

echo get_ctime($month); // 输出

相关文章

网友评论

      本文标题:php根据指定年月份获取月初月末的时间戳

      本文链接:https://www.haomeiwen.com/subject/upkfrqtx.html