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_date = "2009-12-23"
I want 2009-12-31.
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_date = "2009-12-23"
I want 2009-12-31.
http://zkinformer.com/?p=134
t
returns the number of days in the month of a given date (see the docs fordate
):There are ways to get last day of month.
Carbon API extension for PHP DateTime
or
will retrun
An other way using mktime and not date('t') :
So this way it calculates either if it is 31,30 or 29
Using Zend_Date it's pretty easy: