当前位置:Gxlcms > PHP教程 > 帮忙取任意一个月的最后一天解决方案

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

时间:2021-07-01 10:21:17 帮助过:16人阅读

帮忙取任意一个月的最后一天
比如我要输出这个月的最后一天,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函数.

人气教程排行