How to find the last day of the month from date?

后端 未结 28 1508
孤城傲影
孤城傲影 2020-11-22 08:56

How can I get the last day of the month in PHP?

Given:

$a_date = \"2009-11-23\"

I want 2009-11-30; and given

$a_dat         


        
28条回答
  •  忘了有多久
    2020-11-22 08:59

    t returns the number of days in the month of a given date (see the docs for date):

    $a_date = "2009-11-23";
    echo date("Y-m-t", strtotime($a_date));
    

提交回复
热议问题