Home  >  Article  >  Backend Development  >  PHP获取月份最后一天方法

PHP获取月份最后一天方法

WBOY
WBOYOriginal
2016-06-20 13:04:183611browse

PHP获取月份最后一天方法

echo date('Y-m-t'); //获取当前月的最后一天

echo date('Y-m-t',strtotime("09.13.1987")); //获取指定月份的最后一天

//获取指定日期的上个月的最后一天

$curtime="1987-09-13";

$time=strtotime($curtime );

date('Y-m-t',strtotime('last month',$time));

//获取指定日期的下个月的最后一天

$curtime="2010-04-11";

$time=strtotime($curtime );

date('Y-m-t',strtotime('next month',$time));


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