Home > Article > Backend Development > How to get the first and last day of a month in php?
php Get the first and last day of a month and directly enter the code. It is actually a very simple thing.
The code is as follows:
function getthemonth($date) { $firstday = date('Y-m-01', strtotime($date)); $lastday = date('Y-m-d', strtotime("$firstday +1 month -1 day")); return array($firstday, $lastday); }
The above is the detailed content of How to get the first and last day of a month in php?. For more information, please follow other related articles on the PHP Chinese website!