Home  >  Article  >  php教程  >  php获取一个月的第一天和最后一天

php获取一个月的第一天和最后一天

WBOY
WBOYOriginal
2016-06-07 11:39:43955browse

用php来获取一个月的第一天和最后一天,最近要开放任务系统,在某个地方看到的,记录一下,分享给大家,不喜勿喷!
//调用demo<br> $date = date('Y-m-d H:i:s'); //当前时间<br> print_r(getthemonth($date));<br> <br> function getthemonth($date)<br> {<br>     $firstday = date('Y-m-01', strtotime($date));<br>     $lastday = date('Y-m-d', strtotime("$firstday +1 month -1 day"));<br>     return array($firstday, $lastday);<br> }

AD:真正免费,域名+虚机+企业邮箱=0元

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