本文整理汇总了PHP中w2p_Utilities_Date::addMonths方法的典型用法代码示例。如果您正苦于以下问题:PHP w2p_Utilities_Date::addMonths方法的具体用法?PHP w2p_Utilities_Date::addMonths怎么用?PHP w2p_Utilities_Date::addMonths使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类w2p_Utilities_Date
的用法示例。
在下文中一共展示了w2p_Utilities_Date::addMonths方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRecurrentEventforPeriod
/**
* Calculating if an recurrent date is in the given period
* @param Date Start date of the period
* @param Date End date of the period
* @param Date Start date of the Date Object
* @param Date End date of the Date Object
* @param integer Type of Recurrence
* @param integer Times of Recurrence
* @param integer Time of Recurrence
* @return array Calculated Start and End Dates for the recurrent Event for the given Period
*/
public function getRecurrentEventforPeriod($start_date, $end_date, $event_start_date, $event_end_date, $event_recurs, $event_times_recuring, $j)
{
//this array will be returned
$transferredEvent = array();
//create Date Objects for Event Start and Event End
$eventStart = new w2p_Utilities_Date($event_start_date);
$eventEnd = new w2p_Utilities_Date($event_end_date);
//Time of Recurence = 0 (first occurence of event) has to be checked, too.
if ($j > 0) {
switch ($event_recurs) {
case 1:
$eventStart->addSpan(new Date_Span(3600 * $j));
$eventEnd->addSpan(new Date_Span(3600 * $j));
break;
case 2:
$eventStart->addDays($j);
$eventEnd->addDays($j);
break;
case 3:
$eventStart->addDays(7 * $j);
$eventEnd->addDays(7 * $j);
break;
case 4:
$eventStart->addDays(14 * $j);
$eventEnd->addDays(14 * $j);
break;
case 5:
$eventStart->addMonths($j);
$eventEnd->addMonths($j);
break;
case 6:
$eventStart->addMonths(3 * $j);
$eventEnd->addMonths(3 * $j);
break;
case 7:
$eventStart->addMonths(6 * $j);
$eventEnd->addMonths(6 * $j);
break;
case 8:
$eventStart->addMonths(12 * $j);
$eventEnd->addMonths(12 * $j);
break;
default:
break;
}
}
if ($start_date->compare($start_date, $eventStart) <= 0 && $end_date->compare($end_date, $eventEnd) >= 0) {
// add temporarily moved Event Start and End dates to returnArray
$transferredEvent = array($eventStart, $eventEnd);
}
// return array with event start and end dates for given period (positive case)
// or an empty array (negative case)
return $transferredEvent;
}
示例2: scrollNext
$new_end->addMonths(-$scroll_date);
echo "f.project_start_date.value='" . $new_start->format(FMT_TIMESTAMP_DATE) . "';";
echo "f.project_end_date.value='" . $new_end->format(FMT_TIMESTAMP_DATE) . "';";
?>
document.editFrm.display_option.value = 'custom';
f.submit()
}
function scrollNext() {
f = document.editFrm;
<?php
$new_start = new w2p_Utilities_Date($start_date);
$new_start->day = 1;
$new_end = new w2p_Utilities_Date($end_date);
$new_start->addMonths($scroll_date);
$new_end->addMonths($scroll_date);
echo "f.project_start_date.value='" . $new_start->format(FMT_TIMESTAMP_DATE) . "';";
echo "f.project_end_date.value='" . $new_end->format(FMT_TIMESTAMP_DATE) . "';";
?>
document.editFrm.display_option.value = 'custom';
document.editFrm.printpdf.value = "0";
document.editFrm.printpdfhr.value = "0";
f.submit();
}
function showThisMonth() {
document.editFrm.display_option.value = "this_month";
document.editFrm.printpdf.value = "0";
document.editFrm.printpdfhr.value = "0";
document.editFrm.submit();
}
示例3: testAddMonthsNegativeAcrossYear
/**
* Tests addMonths when the number of months spans a year
*/
public function testAddMonthsNegativeAcrossYear()
{
$date = new w2p_Utilities_Date('2010-01-01 00:00:00');
$date->addMonths(-1);
$this->assertEquals('2009-12-01 00:00:00', $date->getDate(DATE_FORMAT_ISO));
}