Home >Backend Development >PHP Tutorial >How to get the first and last day of a month in php?

How to get the first and last day of a month in php?

怪我咯
怪我咯Original
2017-07-10 09:47:164128browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn