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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Rana Amir
Forum Newbie
Posts: 1
Joined: Fri Dec 17, 2010 8:27 pm

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

Post 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
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

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

Post 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:
There are 10 types of people in this world, those who understand binary and those who don't
parino_esquilado
Forum Newbie
Posts: 13
Joined: Wed Apr 22, 2009 12:22 pm

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

Post by parino_esquilado »

I love how simplistic that is :D
Post Reply