php - How can we find First and last day of a date -


possible duplicate:
in php, there easy way first , last date of month?

how can find first , last day of date?

i have date "01/05/2011". getting date dynamically. know last day of date. '31 or 30 or 28 or 29'.

i want find using php...

this function may :

function lastday($month = '', $year = '')     {        if (empty($month)) {           $month = date('m');        }        if (empty($year)) {           $year = date('y');        }        $result = strtotime("{$year}-{$month}-01");        $result = strtotime('-1 second', strtotime('+1 month', $result));        return date('y-m-d', $result);     } 

call like

$month = 3; $year = 2011; $lastday = $this->lastday($month, $year); 

that give last day of march 2011......


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -