当前位置: 首页>>代码示例>>PHP>>正文


PHP Date::Now方法代码示例

本文整理汇总了PHP中Date::Now方法的典型用法代码示例。如果您正苦于以下问题:PHP Date::Now方法的具体用法?PHP Date::Now怎么用?PHP Date::Now使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Date的用法示例。


在下文中一共展示了Date::Now方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: PageLoad

 /**
  * @param UserSession $userSession
  * @param string $timezone
  */
 public function PageLoad($userSession, $timezone)
 {
     $type = $this->page->GetCalendarType();
     $year = $this->page->GetYear();
     $month = $this->page->GetMonth();
     $day = $this->page->GetDay();
     $defaultDate = Date::Now()->ToTimezone($timezone);
     if (empty($year)) {
         $year = $defaultDate->Year();
     }
     if (empty($month)) {
         $month = $defaultDate->Month();
     }
     if (empty($day)) {
         $day = $defaultDate->Day();
     }
     $schedules = $this->scheduleRepository->GetAll();
     $showInaccessible = Configuration::Instance()->GetSectionKey(ConfigSection::SCHEDULE, ConfigKeys::SCHEDULE_SHOW_INACCESSIBLE_RESOURCES, new BooleanConverter());
     $resources = $this->resourceService->GetAllResources($showInaccessible, $userSession);
     $selectedScheduleId = $this->page->GetScheduleId();
     $selectedSchedule = $this->GetDefaultSchedule($schedules);
     $selectedResourceId = $this->page->GetResourceId();
     $calendar = $this->calendarFactory->Create($type, $year, $month, $day, $timezone, $selectedSchedule->GetWeekdayStart());
     $reservations = $this->reservationRepository->GetReservationList($calendar->FirstDay(), $calendar->LastDay()->AddDays(1), $userSession->UserId, ReservationUserLevel::ALL, $selectedScheduleId, $selectedResourceId);
     $calendar->AddReservations(CalendarReservation::FromViewList($reservations, $timezone));
     $this->page->BindCalendar($calendar);
     $this->page->SetDisplayDate($calendar->FirstDay());
     $this->page->BindFilters(new CalendarFilters($schedules, $resources, $selectedScheduleId, $selectedResourceId));
     $this->page->SetScheduleId($selectedScheduleId);
     $this->page->SetResourceId($selectedResourceId);
     $this->page->SetFirstDay($selectedSchedule->GetWeekdayStart());
     $details = $this->subscriptionService->ForUser($userSession->UserId);
     $this->page->BindSubscription($details);
 }
开发者ID:hugutux,项目名称:booked,代码行数:38,代码来源:PersonalCalendarPresenter.php

示例2: GetOngoingReservation

 /**
  * @param ResourceDto $resource
  * @param ReservationItemView[][] $reservations
  * @return ReservationItemView|null
  */
 private function GetOngoingReservation($resource, $reservations)
 {
     if (array_key_exists($resource->GetId(), $reservations) && $reservations[$resource->GetId()][0]->StartDate->LessThan(Date::Now())) {
         return $reservations[$resource->GetId()][0];
     }
     return null;
 }
开发者ID:utn-frm-si,项目名称:booked,代码行数:12,代码来源:ResourceAvailabilityControlPresenter.php

示例3: testScheduleResponseReturnsLayoutForEachDayOfWeek

 public function testScheduleResponseReturnsLayoutForEachDayOfWeek()
 {
     $schedule = new FakeSchedule();
     $layout = $this->getMock('IScheduleLayout');
     $timezone = $this->server->GetSession()->Timezone;
     $date1 = Date::Now()->ToTimezone($timezone);
     $date2 = $date1->AddDays(1);
     $date3 = $date1->AddDays(2);
     $date4 = $date1->AddDays(3);
     $date5 = $date1->AddDays(4);
     $date6 = $date1->AddDays(5);
     $date7 = $date1->AddDays(6);
     $periods1 = array(new SchedulePeriod($date1, $date1));
     $periods2 = array(new SchedulePeriod($date2, $date2));
     $periods3 = array(new SchedulePeriod($date3, $date3));
     $periods4 = array(new SchedulePeriod($date4, $date4));
     $periods5 = array(new SchedulePeriod($date5, $date5));
     $periods6 = array(new SchedulePeriod($date6, $date6));
     $periods7 = array(new SchedulePeriod($date7, $date7));
     $layout->expects($this->at(0))->method('GetLayout')->with($this->equalTo($date1))->will($this->returnValue($periods1));
     $layout->expects($this->at(1))->method('GetLayout')->with($this->equalTo($date2))->will($this->returnValue($periods2));
     $layout->expects($this->at(2))->method('GetLayout')->with($this->equalTo($date3))->will($this->returnValue($periods3));
     $layout->expects($this->at(3))->method('GetLayout')->with($this->equalTo($date4))->will($this->returnValue($periods4));
     $layout->expects($this->at(4))->method('GetLayout')->with($this->equalTo($date5))->will($this->returnValue($periods5));
     $layout->expects($this->at(5))->method('GetLayout')->with($this->equalTo($date6))->will($this->returnValue($periods6));
     $layout->expects($this->at(6))->method('GetLayout')->with($this->equalTo($date7))->will($this->returnValue($periods7));
     $response = new ScheduleResponse($this->server, $schedule, $layout);
     $this->assertEquals(array(new SchedulePeriodResponse($periods1[0])), $response->periods[$date1->Weekday()]);
     $this->assertEquals(array(new SchedulePeriodResponse($periods2[0])), $response->periods[$date2->Weekday()]);
     $this->assertEquals(array(new SchedulePeriodResponse($periods3[0])), $response->periods[$date3->Weekday()]);
     $this->assertEquals(array(new SchedulePeriodResponse($periods4[0])), $response->periods[$date4->Weekday()]);
     $this->assertEquals(array(new SchedulePeriodResponse($periods5[0])), $response->periods[$date5->Weekday()]);
     $this->assertEquals(array(new SchedulePeriodResponse($periods6[0])), $response->periods[$date6->Weekday()]);
     $this->assertEquals(array(new SchedulePeriodResponse($periods7[0])), $response->periods[$date7->Weekday()]);
 }
开发者ID:utn-frm-si,项目名称:booked,代码行数:35,代码来源:SchedulesWebServiceTests.php

示例4: __construct

 public function __construct()
 {
     $this->sessionToken = 'sessiontoken';
     $this->sessionExpires = Date::Now()->ToIso();
     $this->isAuthenticated = true;
     $this->userId = 123;
 }
开发者ID:Trideon,项目名称:gigolo,代码行数:7,代码来源:AuthenticationResponse.php

示例5: testGetReservationsPullsReservationFromTheRepositoryAndAddsThemToTheCoordinator

 public function testGetReservationsPullsReservationFromTheRepositoryAndAddsThemToTheCoordinator()
 {
     $timezone = 'UTC';
     $startDate = Date::Now();
     $endDate = Date::Now();
     $scheduleId = 100;
     $range = new DateRange($startDate, $endDate);
     $repository = $this->getMock('IReservationViewRepository');
     $reservationListing = new TestReservationListing();
     $listingFactory = $this->getMock('IReservationListingFactory');
     $rows = FakeReservationRepository::GetReservationRows();
     $res1 = ReservationItemView::Populate($rows[0]);
     $res2 = ReservationItemView::Populate($rows[1]);
     $res3 = ReservationItemView::Populate($rows[2]);
     $date = Date::Now();
     $blackout1 = new TestBlackoutItemView(1, $date, $date, 1);
     $blackout2 = new TestBlackoutItemView(2, $date, $date, 2);
     $blackout3 = new TestBlackoutItemView(3, $date, $date, 3);
     $repository->expects($this->once())->method('GetReservationList')->with($this->equalTo($startDate), $this->equalTo($endDate), $this->isNull(), $this->isNull(), $this->equalTo($scheduleId), $this->isNull())->will($this->returnValue(array($res1, $res2, $res3)));
     $repository->expects($this->once())->method('GetBlackoutsWithin')->with($this->equalTo(new DateRange($startDate, $endDate)), $this->equalTo($scheduleId))->will($this->returnValue(array($blackout1, $blackout2, $blackout3)));
     $listingFactory->expects($this->once())->method('CreateReservationListing')->with($this->equalTo($timezone))->will($this->returnValue($reservationListing));
     $service = new ReservationService($repository, $listingFactory);
     $listing = $service->GetReservations($range, $scheduleId, $timezone);
     $this->assertEquals($reservationListing, $listing);
     $this->assertTrue(in_array($res1, $reservationListing->reservations));
     $this->assertTrue(in_array($res2, $reservationListing->reservations));
     $this->assertTrue(in_array($res3, $reservationListing->reservations));
     $this->assertTrue(in_array($blackout1, $reservationListing->blackouts));
     $this->assertTrue(in_array($blackout2, $reservationListing->blackouts));
     $this->assertTrue(in_array($blackout3, $reservationListing->blackouts));
 }
开发者ID:utn-frm-si,项目名称:booked,代码行数:31,代码来源:ReservationServiceTests.php

示例6: PageLoad

 public function PageLoad(UserSession $user)
 {
     $now = Date::Now();
     $resources = $this->resourceService->GetAllResources(false, $user);
     $reservations = $this->GetReservations($this->reservationViewRepository->GetReservationList($now, $now));
     $next = $this->reservationViewRepository->GetNextReservations($now);
     $available = array();
     $unavailable = array();
     $allday = array();
     foreach ($resources as $resource) {
         $reservation = $this->GetOngoingReservation($resource, $reservations);
         if ($reservation != null) {
             if (!$reservation->EndDate->DateEquals(Date::Now())) {
                 $allday[] = new UnavailableDashboardItem($resource, $reservation);
             } else {
                 $unavailable[] = new UnavailableDashboardItem($resource, $reservation);
             }
         } else {
             if (array_key_exists($resource->GetId(), $next)) {
                 $available[] = new AvailableDashboardItem($resource, $next[$resource->GetId()]);
             } else {
                 $available[] = new AvailableDashboardItem($resource);
             }
         }
     }
     $this->control->SetAvailable($available);
     $this->control->SetUnavailable($unavailable);
     $this->control->SetUnavailableAllDay($allday);
 }
开发者ID:Trideon,项目名称:gigolo,代码行数:29,代码来源:ResourceAvailabilityControlPresenter.php

示例7: testGetsAllReservationsWithReminderDateOfThisMinute

 public function testGetsAllReservationsWithReminderDateOfThisMinute()
 {
     $seriesId = 123;
     $instanceId = 456;
     $referenceNumber = 'refnum1';
     $startDate = Date::Now()->AddDays(1)->ToDatabase();
     $endDate = Date::Now()->AddDays(2)->ToDatabase();
     $title = 'reservation title';
     $description = 'reservation description';
     $resourceName = 'resource name';
     $emailAddress = 'e@m.com';
     $fname = 'first';
     $lname = 'last';
     $timezone = 'America/Chicago';
     $reminder_minutes = 100;
     $now = Date::Now();
     $language = 'en_us';
     $row1 = new ReminderNoticeRow($seriesId, $instanceId, $referenceNumber, $startDate, $endDate, $title, $description, $resourceName, $emailAddress, $fname, $lname, $timezone, $reminder_minutes, $language);
     $row2 = new ReminderNoticeRow();
     $rows = array_merge($row1->Rows(), $row2->Rows());
     $this->db->SetRows($rows);
     $reminderNotices = $this->repository->GetReminderNotices($now, ReservationReminderType::Start);
     $expectedCommand = new GetReminderNoticesCommand($now->ToTheMinute(), ReservationReminderType::Start);
     $this->assertEquals(2, count($reminderNotices));
     $this->assertEquals($expectedCommand, $this->db->_LastCommand);
     $expectedReminderNotice = ReminderNotice::FromRow($rows[0]);
     $this->assertEquals($expectedReminderNotice, $reminderNotices[0]);
 }
开发者ID:utn-frm-si,项目名称:booked,代码行数:28,代码来源:ReminderRepositoryTests.php

示例8: testCreatesSerializableLayout

 public function testCreatesSerializableLayout()
 {
     $baseDate = Date::Now();
     $b1 = $baseDate->AddDays(1);
     $e1 = $baseDate->AddDays(2);
     $b2 = $baseDate->AddDays(3);
     $e2 = $baseDate->AddDays(4);
     $b3 = $baseDate->AddDays(5);
     $e3 = $baseDate->AddDays(6);
     $b4 = $baseDate->AddDays(7);
     $e4 = $baseDate->AddDays(8);
     $l1 = 'label 1';
     $l2 = 'label 2';
     $p1 = new SchedulePeriod($b1, $e1);
     $p2 = new NonSchedulePeriod($b2, $e2);
     $p3 = new SchedulePeriod($b3, $e3, $l1);
     $p4 = new NonSchedulePeriod($b4, $e4, $l2);
     $periods = array($p1, $p2, $p3, $p4);
     $actual = new ScheduleLayoutSerializable($periods);
     $actualPeriods = $actual->periods;
     $this->assertEquals(count($periods), count($actualPeriods));
     $this->assertEquals($p1->Begin()->__toString(), $actualPeriods[0]->begin);
     $this->assertEquals($p1->End()->__toString(), $actualPeriods[0]->end);
     $this->assertEquals($p1->BeginDate()->__toString(), $actualPeriods[0]->beginDate);
     $this->assertEquals($p1->EndDate()->__toString(), $actualPeriods[0]->endDate);
     $this->assertEquals($p1->Label(), $actualPeriods[0]->label);
     $this->assertEquals($p1->LabelEnd(), $actualPeriods[0]->labelEnd);
     $this->assertEquals($p1->IsReservable(), $actualPeriods[0]->isReservable);
     $this->assertEquals($p2->Begin()->__toString(), $actualPeriods[1]->begin);
     $this->assertEquals($p2->End()->__toString(), $actualPeriods[1]->end);
     $this->assertEquals($p2->Label(), $actualPeriods[1]->label);
     $this->assertEquals($p2->LabelEnd(), $actualPeriods[1]->labelEnd);
     $this->assertEquals($p2->IsReservable(), $actualPeriods[1]->isReservable);
 }
开发者ID:utn-frm-si,项目名称:booked,代码行数:34,代码来源:ScheduleLayoutSerializableTests.php

示例9: __construct

 public function __construct(Date $date)
 {
     $this->date = $date->GetDate();
     if ($this->date->DateEquals(Date::Now())) {
         $this->Highlight();
     }
 }
开发者ID:hugutux,项目名称:booked,代码行数:7,代码来源:CalendarDay.php

示例10: Bind

 public function Bind(IReservationComponentInitializer $initializer)
 {
     $timezone = $initializer->GetTimezone();
     $reservationDate = $initializer->GetReservationDate();
     $requestedEndDate = $initializer->GetEndDate();
     $requestedStartDate = $initializer->GetStartDate();
     $requestedScheduleId = $initializer->GetScheduleId();
     $requestedDate = $reservationDate == null ? Date::Now()->ToTimezone($timezone) : $reservationDate->ToTimezone($timezone);
     $startDate = $requestedStartDate == null ? $requestedDate : $requestedStartDate->ToTimezone($timezone);
     $endDate = $requestedEndDate == null ? $requestedDate : $requestedEndDate->ToTimezone($timezone);
     if ($initializer->IsNew()) {
         $resource = $initializer->PrimaryResource();
         if ($resource->GetMinimumLength() != null && !$resource->GetMinimumLength()->Interval()->IsNull()) {
             $endDate = $startDate->ApplyDifference($resource->GetMinimumLength()->Interval());
         }
     }
     $layout = $this->scheduleRepository->GetLayout($requestedScheduleId, new ReservationLayoutFactory($timezone));
     $startPeriods = $layout->GetLayout($startDate);
     if (count($startPeriods) > 1 && $startPeriods[0]->Begin()->Compare($startPeriods[1]->Begin()) > 0) {
         $period = array_shift($startPeriods);
         $startPeriods[] = $period;
     }
     $endPeriods = $layout->GetLayout($endDate);
     $initializer->SetDates($startDate, $endDate, $startPeriods, $endPeriods);
     $hideRecurrence = !$initializer->CurrentUser()->IsAdmin && Configuration::Instance()->GetSectionKey(ConfigSection::RESERVATION, ConfigKeys::RESERVATION_PREVENT_RECURRENCE, new BooleanConverter());
     $initializer->HideRecurrence($hideRecurrence);
 }
开发者ID:JoseTfg,项目名称:Booked,代码行数:27,代码来源:ReservationComponentBinder.php

示例11: Now

 public static function Now()
 {
     if (empty(self::$Now)) {
         return Date::Now()->ToDatabase();
     } else {
         return date(self::$_format, self::$Now);
     }
 }
开发者ID:Trideon,项目名称:gigolo,代码行数:8,代码来源:LoginTime.php

示例12: __construct

 public function __construct()
 {
     $this->interval = 3;
     $this->monthlyType = RepeatMonthlyType::DayOfMonth . '|' . RepeatMonthlyType::DayOfWeek . '|null';
     $this->type = RepeatType::Daily . '|' . RepeatType::Monthly . '|' . RepeatType::None . '|' . RepeatType::Weekly . '|' . RepeatType::Yearly;
     $this->weekdays = array(0, 1, 2, 3, 4, 5, 6);
     $this->repeatTerminationDate = Date::Now()->ToIso();
 }
开发者ID:hugutux,项目名称:booked,代码行数:8,代码来源:RecurrenceRequestResponse.php

示例13: testCanGetNow

 public function testCanGetNow()
 {
     $format = 'd m y H:i:s';
     Date::_ResetNow();
     $now = Date::Now();
     $datenow = new DateTime(date(Date::SHORT_FORMAT, time()));
     $this->assertEquals($datenow->format($format), $now->Format($format));
 }
开发者ID:utn-frm-si,项目名称:booked,代码行数:8,代码来源:DateTests.php

示例14: PageLoad

 public function PageLoad()
 {
     if (!$this->validator->IsValid()) {
         return;
     }
     $userId = $this->page->GetUserId();
     $scheduleId = $this->page->GetScheduleId();
     $resourceId = $this->page->GetResourceId();
     $accessoryIds = $this->page->GetAccessoryIds();
     $resourceGroupId = $this->page->GetResourceGroupId();
     $weekAgo = Date::Now()->AddDays(-7);
     $nextYear = Date::Now()->AddDays(365);
     $sid = null;
     $rid = null;
     $uid = null;
     $aid = null;
     $resourceIds = array();
     $reservations = array();
     $res = array();
     $summaryFormat = Configuration::Instance()->GetSectionKey(ConfigSection::RESERVATION_LABELS, ConfigKeys::RESERVATION_LABELS_ICS_SUMMARY);
     $reservationUserLevel = ReservationUserLevel::OWNER;
     if (!empty($scheduleId)) {
         $schedule = $this->subscriptionService->GetSchedule($scheduleId);
         $sid = $schedule->GetId();
     }
     if (!empty($resourceId)) {
         $resource = $this->subscriptionService->GetResource($resourceId);
         $rid = $resource->GetId();
     }
     if (!empty($accessoryIds)) {
         ## No transformation is implemented. It is assumed the accessoryIds is provided as AccessoryName
         ## filter is defined by LIKE "PATTERN%"
         $aid = $accessoryIds;
     }
     if (!empty($userId)) {
         $user = $this->subscriptionService->GetUser($userId);
         $uid = $user->Id();
         $reservationUserLevel = ReservationUserLevel::ALL;
         $summaryFormat = Configuration::Instance()->GetSectionKey(ConfigSection::RESERVATION_LABELS, ConfigKeys::RESERVATION_LABELS_MY_ICS_SUMMARY);
     }
     if (!empty($resourceGroupId)) {
         $resourceIds = $this->subscriptionService->GetResourcesInGroup($resourceGroupId);
     }
     if (!empty($uid) || !empty($sid) || !empty($rid) || !empty($resourceIds)) {
         $res = $this->reservationViewRepository->GetReservationList($weekAgo, $nextYear, $uid, $reservationUserLevel, $sid, $rid);
     } elseif (!empty($aid)) {
         throw new Exception('need to give an accessory a public id, allow subscriptions');
         $res = $this->reservationViewRepository->GetAccessoryReservationList($weekAgo, $nextYear, $accessoryIds);
     }
     Log::Debug('Loading calendar subscription for userId %s, scheduleId %s, resourceId %s. Found %s reservations.', $userId, $scheduleId, $resourceId, count($res));
     $session = ServiceLocator::GetServer()->GetUserSession();
     foreach ($res as $r) {
         if (empty($resourceIds) || in_array($r->ResourceId, $resourceIds)) {
             $reservations[] = new iCalendarReservationView($r, $session, $this->privacyFilter, $summaryFormat);
         }
     }
     $this->page->SetReservations($reservations);
 }
开发者ID:JoseTfg,项目名称:Booked,代码行数:58,代码来源:CalendarSubscriptionPresenter.php

示例15: __construct

 public function __construct()
 {
     $now = Date::Now();
     $this->startDate = $now->AddDays(5)->Format('Y-m-d');
     $this->endDate = $now->AddDays(6)->Format('Y-m-d');
     $this->repeatTerminationDate = $now->AddDays(60)->Format('Y-m-d');
     $this->accessories = array(new FakeAccessoryFormElement(1, 2, 'accessoryname'));
     $this->attributes = array(new AttributeFormElement(1, "something"));
     $this->attachment = new FakeUploadedFile();
 }
开发者ID:utn-frm-si,项目名称:booked,代码行数:10,代码来源:FakeReservationSavePage.php


注:本文中的Date::Now方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。