sasnaktiv
asked on
If today's date is 2013-01-22, how can I get Last Month?
RE: date("Y-m-d");
My brain has turned to mush today.
Can anybody tell me how I can get 2012-12-01 when today's date is 2013-01-22?
Basically I'm looking for $LastMonth when this month is January.
Thanks,
Sas
My brain has turned to mush today.
Can anybody tell me how I can get 2012-12-01 when today's date is 2013-01-22?
Basically I'm looking for $LastMonth when this month is January.
Thanks,
Sas
set day = 1; month=month-1; if month ==0 {year=year-1; month=12}
ASKER
Thanks n2fc,
I don't understand how to apply that.
Can you give me a bigger picture?
Sas
I don't understand how to apply that.
Can you give me a bigger picture?
Sas
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Frosty,
That's perfect!
Ray, I'm only getting the month (12) and not the year (2012)
Thanks for the help and attention Guys.
Sas
That's perfect!
Ray, I'm only getting the month (12) and not the year (2012)
Thanks for the help and attention Guys.
Sas
PLEASE READ THE ARTICLE! It's not rocket science but it requires a small investment of time and effort on your part. The date() function has a formatting argument. You simply have to understand the formatting argument to get the answers you want.
https://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_201-Handling-date-and-time-in-PHP-and-MySQL.html
https://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_201-Handling-date-and-time-in-PHP-and-MySQL.html