首页 > Web开发 > 详细

php 获取当月/某月最后一天的时间戳

时间:2014-12-15 17:27:58      阅读:414      评论:0      收藏:0      [点我收藏+]

public function getendmouthtime()

    {

        $date=date("Y-m",time());

        $date_arr=explode(‘-‘,$date);

        $year=$date_arr[0];

        $month=$date_arr[1];

        $days_in_month = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

        

        if ($month < 1 OR $month > 12)

        {

        return 0;

        }

        

        // Is the year a leap year?

        if ($month == 2)

        {

            if ($year%400 == 0 OR ($year%4 == 0 AND $year%100 != 0))

            {

            return $year.‘-‘.$month.‘-29‘;

            }

        }

        return $endstro = strtotime($year.‘-‘.$month.‘-‘.$days_in_month[$month - 1]);

    }


php 获取当月/某月最后一天的时间戳

原文:http://my.oschina.net/jyb2014/blog/356275

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!