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


PHP DateTimeImmutable::createFromMutable方法代码示例

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


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

示例1: __construct

 public function __construct(\DateTimeInterface $date, \DateTimeInterface $baseDate)
 {
     $this->date = $date instanceof \DateTime ? \DateTimeImmutable::createFromMutable($date) : $date;
     $this->baseDate = $baseDate instanceof \DateTime ? \DateTimeImmutable::createFromMutable($baseDate) : $baseDate;
     $this->interval = $date->diff($baseDate);
     $this->diffInSeconds = $date->format('U') - $baseDate->format('U');
     $this->calendarMonths = $this->calculateCalendarMonths();
 }
开发者ID:wookieb,项目名称:relative-date,代码行数:8,代码来源:DateDiffRequest.php

示例2: get

 /**
  * Get the aggregate root if it exists otherwise null
  *
  * @param AggregateType $aggregateType
  * @param string $aggregateId
  * @return Snapshot
  */
 public function get(AggregateType $aggregateType, $aggregateId)
 {
     $gridFs = $this->getGridFs($aggregateType);
     $gridFsfile = $gridFs->findOne(['$query' => ['aggregate_type' => $aggregateType->toString(), 'aggregate_id' => $aggregateId], '$orderBy' => ['last_version' => -1]]);
     if (!$gridFsfile) {
         return;
     }
     return new Snapshot($aggregateType, $aggregateId, unserialize($gridFsfile->getBytes()), $gridFsfile->file['last_version'], \DateTimeImmutable::createFromMutable($gridFsfile->file['created_at']->toDateTime()));
 }
开发者ID:prolic,项目名称:snapshot-mongodb-adapter,代码行数:16,代码来源:MongoDbAdapter.php

示例3: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $repo = App::make(Repository::class);
     $faker = App::make(Faker\Generator::class);
     $genders = ['male', 'female'];
     for ($i = 0; $i < 10; $i++) {
         $id = RegistrationRequestId::generate();
         $gender = $faker->randomElement($genders);
         $request = RegistrationRequest::submit($id, new FullName($faker->firstName($gender), '', $faker->lastName), Gender::fromString($gender), DateTimeImmutable::createFromMutable($faker->dateTimeInInterval('- 30 years', '-16 years')), ContactInfo::describe(new Email($faker->safeEmail), new Address($faker->city, $faker->postCode, $faker->streetAddress)), new StudyDetails('Msc Applied Mathematics', new DateTimeImmutable('2011-09-01'), 's2218356'), new PaymentInfo(true, $faker->boolean));
         $repo->save($request);
     }
 }
开发者ID:ProfessorFrancken,项目名称:ProfessorFrancken,代码行数:17,代码来源:RegistrationRequestSeeder.php

示例4: __construct

 /**
  * @param string|int|\DateTimeInterface $dateTime
  */
 public function __construct($dateTime)
 {
     if ($dateTime instanceof \DateTimeInterface) {
         if ($dateTime instanceof \DateTime) {
             $dateTime = \DateTimeImmutable::createFromMutable($dateTime);
         }
         parent::__construct($dateTime);
     } elseif (is_numeric($dateTime)) {
         parent::__construct(new \DateTimeImmutable(date('Y-m-d H:i:s', $dateTime), new \DateTimeZone(date_default_timezone_get())));
     } else {
         throw new Kdyby\Clock\NotImplementedException(sprintf('Cannot process datetime in given format %s', $dateTime));
     }
 }
开发者ID:kdyby,项目名称:clock,代码行数:16,代码来源:ConstantProvider.php

示例5: convertToPHPValue

 public function convertToPHPValue($value, AbstractPlatform $platform)
 {
     if ($value === null || $value instanceof \DateTimeImmutable) {
         return $value;
     } elseif ($value instanceof \DateTime) {
         return \DateTimeImmutable::createFromMutable($value);
     }
     $val = \DateTimeImmutable::createFromFormat($platform->getDateTimeFormatString(), $value, self::getUtc());
     if (!$val) {
         throw ConversionException::conversionFailedFormat($value, $this->getName(), $platform->getDateTimeFormatString());
     }
     return $val;
 }
开发者ID:Theodia,项目名称:theodia.org,代码行数:13,代码来源:UTCDateTimeType.php

示例6: generate

 /**
  * Generate schedule for selected objects
  *
  * @param \DateTime|null $scheduledStartTime
  * @return Generator
  */
 public function generate(\DateTime $startTime = null)
 {
     if (!$startTime) {
         $startTime = new \DateTimeImmutable();
         $startTime = $startTime->setTime($startTime->format("H"), ceil($startTime->format("i") / 5) * 5);
     }
     if (!$startTime instanceof \DateTimeImmutable) {
         $startTime = \DateTimeImmutable::createFromMutable($startTime);
     }
     foreach ($this->objects as $object) {
         $duration = \DateInterval::createFromDateString(ceil($object->getScheduledDuration() / 5) * 5 . " minutes");
         $endTime = $startTime->add($duration);
         $object->setSheduledStartTime($startTime->format(\DateTime::RFC3339));
         $object->setSheduledEndTime($endTime->format(\DateTime::RFC3339));
         $object->scheduledStartTime = $startTime->format(\DateTime::RFC3339);
         $object->scheduledEndTime = $endTime->format(\DateTime::RFC3339);
         // var_dump([$startTime->format('m-d H:i'), (ceil($object->getScheduledDuration() / 5) * 5)." minutes", $endTime->format('m-d H:i')]);
         $startTime = $endTime;
     }
 }
开发者ID:gallna,项目名称:media-library,代码行数:26,代码来源:ScheduleGenerator.php

示例7: var_dump

<?php

$current = "2014-03-02 16:24:08";
$i = DateTimeImmutable::createFromMutable(date_create($current));
var_dump($i);
$i = DateTimeImmutable::createFromMutable(date_create_immutable($current));
var_dump($i);
开发者ID:badlamer,项目名称:hhvm,代码行数:7,代码来源:DateTimeImmutable_createFromMutable.php

示例8: from

function from($mutable_datetime)
{
    $datetime = DateTimeImmutable::createFromMutable($mutable_datetime);
    $gigasecond = new DateInterval('PT1000000000S');
    return $datetime->add($gigasecond);
}
开发者ID:daveyarwood,项目名称:exercism,代码行数:6,代码来源:gigasecond.php

示例9: testCreateFromMutable

 public function testCreateFromMutable()
 {
     $time = '2000-01-02T03:14:25';
     $mutable = new DateTime($time);
     $immutable = DateTimeImmutable::createFromMutable($mutable);
     $this->assertTrue($immutable instanceof DateTimeImmutable);
 }
开发者ID:comsolit,项目名称:date-time-immutable,代码行数:7,代码来源:DateTimeImmutableTest.php

示例10: getNextTimeOfDispatch

 /**
  * @return \DateTimeImmutable
  */
 private function getNextTimeOfDispatch()
 {
     return \DateTimeImmutable::createFromMutable($this->lastSending)->modify(self::NEXT_DISPATCH);
 }
开发者ID:blitzik,项目名称:vycetky-doctrine,代码行数:7,代码来源:Invitation.php

示例11: DateTime

<?php

$date = new DateTime("2014-06-20 11:45 Europe/London");
$immutable = DateTimeImmutable::createFromMutable($date);
开发者ID:tpunt,项目名称:phan,代码行数:4,代码来源:0155_datetimeimmutable_create_from_mutable_expects_parameter.php

示例12: __construct

 /**
  * Creates a new Card.
  *
  * The values can be any of the following:
  * ```
  * name / p-name - The full/formatted name of the person or organisation
  *                 Can either be a string or a Name object.
  * email / u-email - email address
  * logo / u-logo - a logo representing the person or organisation
  * photo / u-photo
  * url / u-url - home page
  * uid / u-uid - universally unique identifier, typically canonical URL
  * category / p-category - category/tag
  * address / p-adr - An Address object
  * tel / p-tel - telephone number
  * note / p-note - additional notes
  * birthday / dt-bday - birth date
  * key / u-key - cryptographic public key e.g. SSH or GPG
  * org / p-org - affiliated organization, either a string or Card
  *               String values overwrite the p-organization-name field
  * orgName / p-organization-name
  * title / p-job-title - job title
  * role / p-role - description of role
  * impp / u-impp per RFC4770
  * sex / p-sex - biological sex
  * gender / p-gender-identity - gender identity
  * anniversary / dt-anniversary - date of anniversary
  * ```
  *
  * @param array $values The values
  */
 public function __construct(array $values)
 {
     if (array_key_exists('p-name', $values)) {
         if ($values['p-name'] instanceof Name) {
             $this->name = $values['p-name'];
         } else {
             $this->fullName = trim($values['p-name']);
         }
     } elseif (array_key_exists('name', $values)) {
         if ($values['name'] instanceof Name) {
             $this->name = $values['name'];
         } else {
             $this->fullName = trim($values['name']);
         }
     }
     foreach (self::$strings as $mf => $p) {
         if (array_key_exists($mf, $values)) {
             $this->{$p} = trim($values[$mf]);
         } elseif (array_key_exists($p, $values)) {
             $this->{$p} = trim($values[$p]);
         }
     }
     foreach (self::$dates as $mf => $p) {
         if (array_key_exists($mf, $values)) {
             $val = $values[$mf];
             if ($val instanceof \DateTimeInterface) {
                 $this->{$p} = $val instanceof \DateTime ? \DateTimeImmutable::createFromMutable($val) : $val;
             }
         } elseif (array_key_exists($p, $values)) {
             $val = $values[$p];
             if ($val instanceof \DateTimeInterface) {
                 $this->{$p} = $val instanceof \DateTime ? \DateTimeImmutable::createFromMutable($val) : $val;
             }
         }
     }
     if (array_key_exists('p-adr', $values)) {
         if ($values['p-adr'] instanceof Address) {
             $this->address = $values['p-adr'];
         }
     } elseif (array_key_exists('address', $values)) {
         if ($values['address'] instanceof Address) {
             $this->address = $values['address'];
         }
     }
     if (array_key_exists('p-org', $values)) {
         if ($values['p-org'] instanceof Card) {
             $this->org = $values['p-org'];
         } else {
             $this->orgName = trim($values['p-org']);
         }
     } elseif (array_key_exists('org', $values)) {
         if ($values['org'] instanceof Card) {
             $this->org = $values['org'];
         } else {
             $this->orgName = trim($values['org']);
         }
     }
 }
开发者ID:libreworks,项目名称:microformats,代码行数:89,代码来源:Card.php

示例13: buildRefreshToken

 private function buildRefreshToken(AccessToken $accessToken)
 {
     $refreshToken = null;
     if ($this->configuration->alwaysGenerateARefreshToken()) {
         $token = $this->configuration->getTokenGenerator()->generate(['length' => $this->configuration->getAccessTokenLength()]);
         $expiresAt = new \DateTime('now', new \DateTimeZone('UTC'));
         $expiresAt->add(\DateInterval::createFromDateString(sprintf("%d seconds", $this->configuration->getRefreshTokenTTL())));
         $refreshToken = new RefreshToken($token, $accessToken, \DateTimeImmutable::createFromMutable($expiresAt));
         $this->refreshTokenStorage->save($refreshToken);
     }
     return $refreshToken;
 }
开发者ID:borisguery,项目名称:oauth2-server,代码行数:12,代码来源:AuthorizationServer.php


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