本文整理汇总了PHP中Date_Calc::addMonthsToDays方法的典型用法代码示例。如果您正苦于以下问题:PHP Date_Calc::addMonthsToDays方法的具体用法?PHP Date_Calc::addMonthsToDays怎么用?PHP Date_Calc::addMonthsToDays使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Date_Calc
的用法示例。
在下文中一共展示了Date_Calc::addMonthsToDays方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: endOfMonthBySpan
/**
* Returns date of the last day of the month in the number of months
* from the given date
*
* @param int $months the number of months from the date provided.
* Positive numbers go into the future.
* Negative numbers go into the past.
* 0 is the month presented in $month.
* @param string $month the month, default is current local month
* @param string $year the year in four digit format, default is the
* current local year
* @param string $format the string indicating how to format the output
*
* @return string the date in the desired format
* @access public
* @static
* @since Method available since Release 1.4.4
*/
function endOfMonthBySpan($months = 0, $month = 0, $year = null, $format = DATE_CALC_FORMAT)
{
if (is_null($year)) {
$year = Date_Calc::dateNow('%Y');
}
if (empty($month)) {
$month = Date_Calc::dateNow('%m');
}
$hn_days = Date_Calc::addMonthsToDays($months + 1, Date_Calc::firstDayOfMonth($month, $year)) - 1;
return Date_Calc::daysToDate($hn_days, $format);
}