得到一个月的最后一天? [英] Get the last day of the month?
本文介绍了得到一个月的最后一天?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有PHP中的任何函数,如 $ date-> getMonthDays()
或 $ date-> getLastDayOfMonth()
某个月(或最后一天的数字)中的天数?
Is there any function like $date->getMonthDays()
or $date->getLastDayOfMonth()
in PHP to get the number of days in a given month (or the last day number)?
$start = new DateTime('2012-02-01');
$end = clone $start;
// Interval = last day of the month minus current day in $start
$interval = $start->getLastDayOfMonth() - intval($start->format('j'));
$end->add(new DateInterval('P' . $interval . 'D'));
编辑:谢谢,投票关闭,这是重复的,抱歉请问...
thanks, voted to close, it's a duplicate, sorry for asking...
推荐答案
php date函数给你带有't'的月份天数
The php date function gives you the number of days in the month with 't'
date("t");
请参阅: http://php.net/manual/en/function.date.php
这篇关于得到一个月的最后一天?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文