本文整理匯總了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);
}