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?

怪我咯
Release: 2023-03-13 10:20:01
Original
4127 people have browsed it

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); 
}
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template