Link to home
Start Free TrialLog in
Avatar of VAL1N
VAL1N

asked on

PHP - First and last day of last month.

Hi, I need to know the first and the last day of the current month and last month.

I use this:

   function firstOfMonth()
                        {
                            return date("Y-m-d H:i:s", strtotime(date('m') . '/01/' . date('Y') . ' 00:00:00'));
                        }
                        function lastOfMonth()
                        {
                            return date("Y-m-d H:i:s", strtotime('-1 second', strtotime('+1 month', strtotime(date('m') . '/01/' . date('Y') . ' 00:00:00'))));
                        }

to find out the first and the last date of the current month, but how do I find out the first and the last day of the last month?

Thank you.
SOLUTION
Avatar of Roger Baklund
Roger Baklund
Flag of Norway image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial