Page 1 of 1

Gettin 1st day and last day of previous month..

Posted: Fri Dec 17, 2010 8:33 pm
by Rana Amir
hello every boddy i've a little trouble to getting 1st day and last day of previous month.....
i can get 1st day and last day of current month
like
function firstOfMonth() {
return date("Y-m-d", strtotime(date('m').'/01/'.date('Y').' 00:00:00'));
}
function lastOfMonth() {
return date("m/d/Y", strtotime('-1 second',strtotime('+1 month',strtotime(date('m').'/01/'.date('Y').' 00:00:00'))));
}


but i cant get 1st day and last day of the previous month... plz help me

Re: Gettin 1st day and last day of previous month..

Posted: Sat Dec 18, 2010 4:13 am
by VladSun

Code: Select all

echo date("Y-m-d",strtotime('first day of previous month'));
echo date("Y-m-d",strtotime('last day of previous month'));
:lol:

Re: Gettin 1st day and last day of previous month..

Posted: Sat Dec 18, 2010 4:16 am
by parino_esquilado
I love how simplistic that is :D