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

WBOY
Release: 2016-06-23 13:43:23
Original
2134 people have browsed it

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 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]);

    }


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template