可能重复:
PHP的最后一天
有没有想任何功能$date->getMonthDays()
或$date->getLastDayOfMonth()
在PHP中获得的天在给定月份数(或最后一天数)?
$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'));
Run Code Online (Sandbox Code Playgroud)
编辑:谢谢,投票结束,这是重复,抱歉...
小智 70
php日期函数为您提供't'的月份天数
date("t");
Run Code Online (Sandbox Code Playgroud)
请参阅:http://php.net/manual/en/function.date.php
Mar*_*jnG 26
上个月约会很简单
echo date("Y-m-t", strtotime("-1 month") ) ;
echo date("Y-m-1", strtotime("-1 month") ) ;
Run Code Online (Sandbox Code Playgroud)
3月3日回归
2011-02-28
2011-02-1
Run Code Online (Sandbox Code Playgroud)
t
为您提供当月的总天数.j
为您提供当月的当天.
使用modify
和format
日期时间的一些减法,你可以到月底.
$date = new DateTime();
$lastDayOfMonth = $date->modify(
sprintf('+%d days', $date->format('t') - $date->format('j'))
);
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
73551 次 |
最近记录: |