Home > Backend Development > PHP Tutorial > php 获取任意月的最后一天

php 获取任意月的最后一天

WBOY
Release: 2016-06-20 13:03:43
Original
3374 people have browsed it

php获取任意月份的最后一天,具体例子如下:

<p>echo date('Y-m-t'); //获取当前月的最后一天</p>echo date('Y-m-t',strtotime("09.13.1987")); //获取指定月份的最后一天<br /><br />//获取指定日期的上个月的最后一天<br />$curtime="1987-09-13";<br />$time=strtotime($curtime );<br />date('Y-m-t',strtotime('last month',$time));<br /><br />//获取指定日期的下个月的最后一天<br />$curtime="2010-04-11";<br />$time=strtotime($curtime );<br />date('Y-m-t',strtotime('next month',$time));
Copy after login


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