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


PHP TimeDate::now方法代码示例

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


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

示例1: build

 /**
  * {@inheritDoc}
  */
 protected function build($builder)
 {
     $durations = \Service::getParameter('bzion.league.duration');
     foreach ($durations as $duration => &$value) {
         $durations[$duration] = $duration;
     }
     return $builder->add('first_team', new MatchTeamType())->add('second_team', new MatchTeamType())->add('duration', 'choice', array('choices' => $durations, 'constraints' => new NotBlank(), 'expanded' => true))->add('server_address', 'text', array('required' => false, 'attr' => array('placeholder' => 'brad.guleague.org:5100')))->add('time', new DatetimeWithTimezoneType(), array('constraints' => array(new NotBlank(), new LessThan(array('value' => \TimeDate::now()->addMinutes(10), 'message' => 'The timestamp of the match must not be in the future'))), 'data' => \TimeDate::now(\Controller::getMe()->getTimezone())))->add('enter', 'submit');
 }
开发者ID:kleitz,项目名称:bzion,代码行数:11,代码来源:MatchFormCreator.php

示例2: build

 /**
  * {@inheritdoc}
  */
 protected function build($builder)
 {
     $durations = \Service::getParameter('bzion.league.duration');
     foreach ($durations as $duration => &$value) {
         $durations[$duration] = $duration;
     }
     return $builder->add('first_team', new MatchTeamType(), array('disableTeam' => $this->isEdit() && $this->editing->isOfficial()))->add('second_team', new MatchTeamType(), array('disableTeam' => $this->isEdit() && $this->editing->isOfficial()))->add('duration', 'choice', array('choices' => $durations, 'constraints' => new NotBlank(), 'expanded' => true))->add('server_address', 'text', array('required' => false, 'attr' => array('placeholder' => 'brad.guleague.org:5100')))->add('time', new DatetimeWithTimezoneType(), array('constraints' => array(new NotBlank(), new LessThan(array('value' => \TimeDate::now()->addMinutes(10), 'message' => 'The timestamp of the match must not be in the future'))), 'data' => $this->isEdit() ? $this->editing->getTimestamp()->setTimezone(\Controller::getMe()->getTimezone()) : \TimeDate::now(\Controller::getMe()->getTimezone()), 'with_seconds' => $this->isEdit()))->add('map', new ModelType('Map'), array('required' => false))->add('type', 'choice', array('choices' => array(\Match::OFFICIAL => 'Official', \Match::FUN => 'Fun match', \Match::SPECIAL => 'Special event match'), 'disabled' => $this->editing && $this->editing->isOfficial(), 'label' => 'Match Type'))->add('enter', 'submit');
 }
开发者ID:allejo,项目名称:bzion,代码行数:11,代码来源:MatchFormCreator.php

示例3: testCache

 public function testCache()
 {
     $this->_setPrefs("Y-m-d", "H:i:s", "GMT");
     $this->time_date->allow_cache = true;
     $now1 = $this->time_date->now();
     sleep(2);
     $now2 = $this->time_date->now();
     $this->assertEquals($now1, $now2, "now() should produce same result when cached");
 }
开发者ID:nickpro,项目名称:sugarcrm_dev,代码行数:9,代码来源:TimeDateTest.php

示例4: testAutomaticExpiry

 public function testAutomaticExpiry()
 {
     $victim = $this->getNewPlayer();
     $ban = Ban::addBan($victim->getId(), $this->getNewPlayer()->getId(), TimeDate::now()->addDay(), "Reason");
     $this->assertTrue($victim->isBanned());
     $this->assertEquals(Ban::getBan($victim->getId())->getId(), $ban->getId());
     $ban->setExpiration(TimeDate::now()->subDay());
     $this->assertFalse($victim->isBanned());
     $this->assertNull(Ban::getBan($victim->getId()));
 }
开发者ID:blast007,项目名称:bzion,代码行数:10,代码来源:BanTest.php

示例5: handleAdminNotesForm

 /**
  * Handle the admin notes form
  * @param  Form   $form   The form
  * @param  Player $player The player in question
  * @param  Player $me     The currently logged in player
  * @return Form   The updated form
  */
 private function handleAdminNotesForm($form, $player, $me)
 {
     $notes = $form->get('notes')->getData();
     if ($form->get('save_and_sign')->isClicked()) {
         $notes .= ' — ' . $me->getUsername() . ' on ' . TimeDate::now()->toRFC2822String();
     }
     $player->setAdminNotes($notes);
     $this->getFlashBag()->add('success', "The admin notes for {$player->getUsername()} have been updated");
     // Reset the form so that the user sees the updated admin notes
     return $this->creator->create();
 }
开发者ID:bchhun,项目名称:bzion,代码行数:18,代码来源:PlayerController.php

示例6: acceptAction

 public function acceptAction(Invitation $invitation, Player $me)
 {
     if (!$me->isTeamless()) {
         throw new ForbiddenException("You can't join a new team until you leave your current one.");
     }
     if ($invitation->getInvitedPlayer()->getId() != $me->getId()) {
         throw new ForbiddenException("This invitation isn't for you!");
     }
     if ($invitation->getExpiration()->lt(TimeDate::now())) {
         throw new ForbiddenException("This invitation has expired");
     }
     $inviter = $invitation->getSentBy()->getEscapedUsername();
     $team = $invitation->getTeam();
     return $this->showConfirmationForm(function () use($invitation, $team, $me) {
         $team->addMember($me->getId());
         $invitation->updateExpiration();
         Service::getDispatcher()->dispatch(Events::TEAM_JOIN, new TeamJoinEvent($team, $me));
         return new RedirectResponse($team->getUrl());
     }, "Are you sure you want to accept the invitation from {$inviter} to join {$team->getEscapedName()}?", "You are now a member of {$team->getName()}");
 }
开发者ID:kleitz,项目名称:bzion,代码行数:20,代码来源:InvitationController.php

示例7: transform

 /**
  * Take a timezone and put its value on the time and timezone fields, so the
  * user can see it
  *
  * @param  string $timezone The timezone
  * @return null|string
  */
 public function transform($timezone)
 {
     if ($timezone === null) {
         return null;
     }
     $timezones = array_keys($this->timezones);
     // The provided timezone is in the reduced list of timezones that we
     // show to the user, so we can use it immediately
     if (in_array($timezone, $timezones)) {
         return $timezone;
     }
     // The timezone isn't in the list, just find one with the same offset
     // and use that instead
     foreach ($timezones as $t) {
         if (\TimeDate::now()->setTimezone($t)->offset === \TimeDate::now()->setTimezone($timezone)->offset) {
             return $t;
         }
     }
     return 'UTC';
     // Default if we can't find a timezone
 }
开发者ID:blast007,项目名称:bzion,代码行数:28,代码来源:TimezoneTransformer.php

示例8: getSummary

 /**
  * Get a count for each month's matches
  *
  * @param Team $team The team in question
  * @return array
  */
 public function getSummary(Team $team)
 {
     $this->groupByMonth();
     $query = $this->createQuery("YEAR(timestamp) as y, MONTH(timestamp) as m, COUNT(*) as count");
     $matches = array();
     $results = Database::getInstance()->query($query, $this->types, $this->parameters);
     foreach ($results as $match) {
         $matches[$match['y'] . '-' . sprintf('%02d', $match['m'])] = $match['count'];
     }
     // Add entries for dates with 0 matches
     $timestamp = $team->getCreationDate()->setTimezone('UTC')->startOfMonth();
     while ($timestamp->lte(TimeDate::now())) {
         $key = $timestamp->format('Y-m');
         if (!isset($matches[$key])) {
             $matches[$key] = 0;
         }
         $timestamp->addMonth();
     }
     ksort($matches);
     return $matches;
 }
开发者ID:blast007,项目名称:bzion,代码行数:27,代码来源:MatchQueryBuilder.php

示例9: updateEditTimestamp

 /**
  * Update the last edit timestamp
  * @return self
  */
 public function updateEditTimestamp()
 {
     return $this->updateProperty($this->updated, "updated", TimeDate::now(), 's');
 }
开发者ID:bchhun,项目名称:bzion,代码行数:8,代码来源:Page.php

示例10: build

 /**
  * {@inheritdoc}
  */
 protected function build($builder)
 {
     return $builder->add('player', new AdvancedModelType('player'), array('constraints' => new NotBlank(), 'disabled' => $this->isEdit(), 'data' => $this->controller->data->get('player')))->add($builder->create('automatic_expiration', 'checkbox', array('data' => true, 'required' => false))->setDataLocked(false))->add($builder->create('expiration', 'datetime', array('data' => \TimeDate::now()))->setDataLocked(false))->add('reason', 'textarea', array('constraints' => new NotBlank(), 'required' => true))->add('server_join_allowed', 'checkbox', array('data' => true, 'required' => false))->add('server_message', 'text', array('required' => false, 'constraints' => new Length(array('max' => 150))))->add('ip_addresses', new IpType(), array('required' => false))->add('enter', 'submit')->setDataLocked(false);
 }
开发者ID:blast007,项目名称:bzion,代码行数:7,代码来源:BanFormCreator.php

示例11: updateExpiration

 /**
  * Mark the invitation as having expired
  *
  * @return self
  */
 public function updateExpiration()
 {
     return $this->updateProperty($this->expiration, 'expiration', TimeDate::now(), 's');
 }
开发者ID:bchhun,项目名称:bzion,代码行数:9,代码来源:Invitation.php

示例12: updateLastLogin

 /**
  * Updates this player's last login
  */
 public function updateLastLogin()
 {
     $this->update("last_login", TimeDate::now()->toMysql(), 's');
 }
开发者ID:bchhun,项目名称:bzion,代码行数:7,代码来源:Player.php

示例13: getOldestTimestamp

 /**
  * Make sure that we are not using expired sessions
  * @return string The oldest timestamp that is not considered expired, in a
  *                MySQL-readable format
  */
 private function getOldestTimestamp()
 {
     $maxLifetime = (int) ini_get('session.gc_maxlifetime');
     $oldestTimestamp = \TimeDate::now()->subSeconds($maxLifetime);
     return $oldestTimestamp->toMysql();
 }
开发者ID:blast007,项目名称:bzion,代码行数:11,代码来源:DatabaseSessionHandler.php

示例14: staleInfo

 /**
  * Checks if the last update is older than or equal to the update interval
  * @return bool Whether the information is older than the update interval
  */
 public function staleInfo()
 {
     $update_time = $this->updated->copy();
     $update_time->modify(Service::getParameter('bzion.miscellaneous.update_interval'));
     return TimeDate::now() >= $update_time;
 }
开发者ID:kleitz,项目名称:bzion,代码行数:10,代码来源:Server.php

示例15: parseChangelog

 /**
  * Get a list of changes that will be shown to the user
  *
  * @param  array[] $changelog The parsed changelog.yml file
  * @return array[] The changes to show to the user
  */
 private function parseChangelog($changelog)
 {
     $listed = array();
     $firstEntry = true;
     $lastChangeDate = \TimeDate::now()->startOfDay();
     $lastChanges = array();
     foreach ($changelog as $date => $changes) {
         $date = \TimeDate::from($date);
         if ($firstEntry) {
             // The array has been sorted, the first entry represents the
             // most recent change. Store its date so that we don't show the
             // same entry many times
             $firstEntry = false;
             if ($lastChangeDate >= $date) {
                 $lastChangeDate = $date;
                 $lastChanges = $changes;
             }
         }
         // Don't list changes that we've listed before
         if ($date == $this->lastUpdateDate) {
             $this->filterAlreadyListedChanges($changes);
         } elseif ($this->lastUpdateDate && $date < $this->lastUpdateDate) {
             break;
         }
         $listed = array_merge_recursive($listed, $changes);
     }
     $this->alreadyListedChanges = $lastChanges;
     $this->lastUpdateDate = $lastChangeDate;
     return $listed;
 }
开发者ID:kleitz,项目名称:bzion,代码行数:36,代码来源:ChangesCommand.php


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