Home > Backend Development > PHP Tutorial > 帮忙取任意一个月的最后一天解决方案

帮忙取任意一个月的最后一天解决方案

WBOY
Release: 2016-06-13 10:23:48
Original
974 people have browsed it

帮忙取任意一个月的最后一天
比如我要输出这个月的最后一天,20120531

------解决方案--------------------
echo '这个月的最后一天是:' .date('Y-m-t', strtotime('this month'));
------解决方案--------------------
$day='20120602';
$days=date('t',strtotime($day));
$d= date("j",strtotime($day));
echo date("Y-m-d",strtotime(($days-$d)." day $day"));
------解决方案--------------------
echo "本月最后一天日期:".date('Y-m-t');

任意月的话就将时间戳数据赋给 date函数.

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