本文整理汇总了PHP中CDate::addMonths方法的典型用法代码示例。如果您正苦于以下问题:PHP CDate::addMonths方法的具体用法?PHP CDate::addMonths怎么用?PHP CDate::addMonths使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDate
的用法示例。
在下文中一共展示了CDate::addMonths方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
*/
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 CDate($event_start_date);
$eventEnd = new CDate($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.sdate.value="' . $new_start->format(FMT_TIMESTAMP_DATE) . '";';
echo 'f.edate.value="' . $new_end->format(FMT_TIMESTAMP_DATE) . '";';
?>
document.editFrm.display_option.value = "custom";
f.submit()
}
function scrollNext() {
f = document.editFrm;
<?php
$new_start = new CDate($start_date);
$new_start->day = 1;
$new_end = new CDate($end_date);
$new_start->addMonths($scroll_date);
$new_end->addMonths($scroll_date);
echo 'f.sdate.value="' . $new_start->format(FMT_TIMESTAMP_DATE) . '";';
echo 'f.edate.value="' . $new_end->format(FMT_TIMESTAMP_DATE) . '";';
?>
document.editFrm.display_option.value = "custom";
f.submit()
}
function showThisMonth() {
document.editFrm.display_option.value = "this_month";
document.editFrm.submit();
}
function showFullProject() {
document.editFrm.display_option.value = "all";
document.editFrm.submit();
示例3: CDate
$AppUI->setState('TimecardMonthlyUserId', $_GET['user_id']);
} else {
$AppUI->setState('TimecardMonthlyUserId', $AppUI->user_id);
}
$user_id = $AppUI->getState('TimecardMonthlyUserId') ? $AppUI->getState('TimecardMonthlyUserId') : 0;
} else {
$user_id = $AppUI->user_id;
}
$start_report = new CDate();
$start_report->setMonth($month);
$start_report->setYear($year);
$start_report->setDay(1);
$start_report->setTime(0, 0, 0);
$end_report = new CDate();
$end_report->copy($start_report);
$end_report->addMonths(1);
$end_report->addDays(-1);
$end_report->setTime(23, 59, 59);
//Get hash of users
$sql = "SELECT user_id, contact_email, concat(contact_last_name,' ',contact_first_name) as name FROM users LEFT JOIN contacts AS c ON users.user_contact = contact_id ORDER BY contact_last_name, contact_first_name;";
$result = db_loadList($sql);
$people = array();
// users list
foreach ($result as $row) {
$people[$row['user_id']] = $row;
$users[$row['user_id']] = $row['name'];
}
unset($result);
$sql = "\r\n select distinct(project_id), project_name from task_log\r\n left join tasks on tasks.task_id = task_log.task_log_task\r\n left join projects on projects.project_id = tasks.task_project\r\n where\r\n task_log_date >= '" . $start_report->format(FMT_DATETIME_MYSQL) . "'\r\n and task_log_date <= '" . $end_report->format(FMT_DATETIME_MYSQL) . "'\r\n and task_log_task != 0\r\n and task_log_creator = " . $user_id . "\r\n order by project_name\r\n\t\t";
# echo $sql;
$projects = array();
示例4: scrollPrev
natsort($projFilter);
// months to scroll
$scroll_date = 1;
$display_option = dPgetParam($_POST, 'display_option', 'this_month');
// format dates
$df = $AppUI->getPref('SHDATEFORMAT');
if ($display_option == 'custom') {
// custom dates
$start_date = intval($sdate) ? new CDate($sdate) : new CDate();
$end_date = intval($edate) ? new CDate($edate) : new CDate();
} else {
// month
$start_date = new CDate();
$start_date->day = 1;
$end_date = new CDate($start_date);
$end_date->addMonths($scroll_date);
}
// setup the title block
if (!@$min_view) {
$titleBlock = new CTitleBlock('Gantt Chart');
$titleBlock->addButton('projects list', '?m=projects');
$titleBlock->show();
}
?>
<script language="javascript">
function scrollPrev() {
f = document.editFrm;
<?php
$new_start = $start_date;