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.
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
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 CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.