本文整理汇总了PHP中w2p_Utilities_Date::getDaysInMonth方法的典型用法代码示例。如果您正苦于以下问题:PHP w2p_Utilities_Date::getDaysInMonth方法的具体用法?PHP w2p_Utilities_Date::getDaysInMonth怎么用?PHP w2p_Utilities_Date::getDaysInMonth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类w2p_Utilities_Date
的用法示例。
在下文中一共展示了w2p_Utilities_Date::getDaysInMonth方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: hook_calendar
public function hook_calendar($userId)
{
$date = new w2p_Utilities_Date(w2PgetParam($_GET, 'date', null));
$date->setTime(0, 0, 0);
$start = $date->duplicate();
$end = $date->duplicate();
$view = w2PgetParam($_GET, 'a', 'month_view');
switch ($view) {
case 'day_view':
break;
case 'week_view':
$end->addDays(6);
break;
case 'index':
case 'month_view':
$start->setDay(1);
$end->setDay($date->getDaysInMonth());
break;
case 'year_view':
$start->setMonth(1);
$start->setDay(1);
$end->setMonth(12);
$end->setDay(31);
break;
}
$end->setTime(23, 59, 59);
$holidays = HolidayFunctions::getHolidaysForDatespan($start, $end, $userId);
$itemsList = array();
foreach ($holidays as $i => $holiday) {
$date = $holiday['startDate'];
$end = $holiday['endDate'];
while (!$date->after(clone $end)) {
$itemsList[] = array('id' => $holiday['id'], 'name' => $holiday['name'], 'startDate' => $date->format(FMT_TIMESTAMP_DATE), 'endDate' => $date->format(FMT_TIMESTAMP_DATE), 'description' => $holiday['description']);
$date = $date->getNextDay();
}
}
return $itemsList;
}
示例2: array
$first_time->setTime(0, 0, 0);
// if Sunday is the 1st, we don't need to go back
// as that's the first day shown on the calendar
if ($first_time->getDayOfWeek() != 0) {
$last_day_of_previous_month = $first_time->getPrevDay();
$day_of_previous_month = $last_day_of_previous_month->getDayOfWeek();
$seconds_to_sub_in_previous_month = 86400 * $day_of_previous_month;
// need to cast it to int because Pear::Date_Span::set down the line
// fails to set the seconds correctly
$last_day_of_previous_month->subtractSeconds((int) $seconds_to_sub_in_previous_month);
$first_time->setDay($last_day_of_previous_month->getDay());
$first_time->setMonth($last_day_of_previous_month->getMonth());
$first_time->setYear($last_day_of_previous_month->getYear());
}
$last_time = new w2p_Utilities_Date($date);
$last_time->setDay($date->getDaysInMonth());
$last_time->setTime(23, 59, 59);
// if Saturday is the last day of month, we don't need to go forward
// as that's the last day shown on the calendar
if ($last_time->getDayOfWeek() != 6) {
$first_day_of_next_month = $last_time->getNextDay();
$day_of_next_month = $first_day_of_next_month->getDayOfWeek();
$seconds_to_add_in_next_month = 86400 * $day_of_next_month;
// need to cast it to int because Pear::Date_Span::set down the line
// fails to set the seconds correctly
$first_day_of_next_month->addSeconds((int) $seconds_to_add_in_next_month);
$last_time->setDay($first_day_of_next_month->getDay());
$last_time->setMonth($first_day_of_next_month->getMonth());
$last_time->setYear($first_day_of_next_month->getYear());
}
$links = array();
示例3: testGetDaysInMonth
/**
* Tests getDaysInMonth
*/
public function testGetDaysInMonth()
{
$date = new w2p_Utilities_Date('2010-11-05 11:00:00');
$this->assertEquals(30, $date->getDaysInMonth());
$date->setMonth(12);
$this->assertEquals(31, $date->getDaysInMonth());
}