Home > Backend Development > PHP Tutorial > php code to get the first and last day of this month

php code to get the first and last day of this month

WBOY
Release: 2016-07-25 08:57:02
Original
2004 people have browsed it
Let me introduce how to use php to get the codes of the first and last day of a month. Friends in need can refer to it.

Use php to get the first and last day of a month. Code:

<?php
/**
* php date函数示例
* 取一个月的第一天与最后一天
* by bbs.it-home.org
*/
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


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