Ads

Tuesday, 9 June 2015

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

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

 $a_date = "2009-11-23"  

I want last day of the month like 2009-11-30

 string date ( string $format [, int $timestamp = time() ] )  

Date function has format string "t", returns the number of days in the month of a given date (see the date document)

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