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


PHP DateTimeInterface::getTimestamp方法代码示例

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


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

示例1: getSeconds

 /**
  * Calculate the number of seconds with the given delay.
  *
  * @param int|\DateTimeInterface $delay
  *
  * @return int
  */
 protected function getSeconds($delay) : int
 {
     if ($delay instanceof DateTimeInterface) {
         return max(0, $delay->getTimestamp() - $this->getTime());
     }
     return (int) $delay;
 }
开发者ID:narrowspark,项目名称:framework,代码行数:14,代码来源:AbstractQueue.php

示例2: getSerializedDirectMessageDelete

 /**
  * @return \stdClass
  */
 private function getSerializedDirectMessageDelete()
 {
     $serializedTweetDelete = new \stdClass();
     $serializedTweetDelete->delete = new \stdClass();
     $serializedTweetDelete->delete->direct_message = new \stdClass();
     $serializedTweetDelete->delete->direct_message->id = $this->id;
     $serializedTweetDelete->delete->direct_message->user_id = $this->userId;
     $serializedTweetDelete->delete->timestamp_ms = $this->date->getTimestamp() * 1000;
     return $serializedTweetDelete;
 }
开发者ID:remi-san,项目名称:twitter,代码行数:13,代码来源:DeleteSerializerTest.php

示例3: __construct

 public function __construct(\DateTimeInterface $date = NULL)
 {
     if ($date === NULL) {
         $this->date = new \DateTimeImmutable();
     } else {
         $this->date = new \DateTimeImmutable('@' . $date->getTimestamp(), $date->getTimezone());
     }
 }
开发者ID:koolkode,项目名称:http,代码行数:8,代码来源:AbstractDateHeader.php

示例4: setDueDate

 public function setDueDate(\DateTimeInterface $dueDate = NULL)
 {
     if ($dueDate === NULL) {
         $this->dueDate = NULL;
     } else {
         $this->dueDate = $dueDate->getTimestamp();
     }
 }
开发者ID:Lesspion,项目名称:bpmn,代码行数:8,代码来源:CreateUserTaskCommand.php

示例5: __construct

 /**
  * @param string $token
  * @param \DateTimeInterface $expiry
  */
 public function __construct($token, \DateTimeInterface $expiry)
 {
     $this->token = $token;
     if ($expiry instanceof \DateTimeImmutable) {
         $this->expiry = $expiry;
     } else {
         $this->expiry = new \DateTimeImmutable('@' . $expiry->getTimestamp());
     }
 }
开发者ID:moneymaxim,项目名称:TrustpilotAuthenticator,代码行数:13,代码来源:AccessToken.php

示例6: setDateTime

 /**
  * Set the date-time of the Date in this Header.
  *
  * If a DateTime instance is provided, it is converted to DateTimeImmutable.
  *
  * @param DateTimeInterface $dateTime
  */
 public function setDateTime(DateTimeInterface $dateTime)
 {
     $this->clearCachedValueIf($this->getCachedValue() != $dateTime->format(DateTime::RFC2822));
     if ($dateTime instanceof DateTime) {
         $immutable = new DateTimeImmutable('@' . $dateTime->getTimestamp());
         $dateTime = $immutable->setTimezone($dateTime->getTimezone());
     }
     $this->dateTime = $dateTime;
 }
开发者ID:tweakers-dev,项目名称:swiftmailer,代码行数:16,代码来源:DateHeader.php

示例7: transform

 /**
  * Transforms a DateTime object into a timestamp in the configured timezone.
  *
  * @param \DateTime|\DateTimeInterface $dateTime A DateTime object
  *
  * @return int A timestamp
  *
  * @throws TransformationFailedException If the given value is not an instance
  *                                       of \DateTime or \DateTimeInterface
  */
 public function transform($dateTime)
 {
     if (null === $dateTime) {
         return;
     }
     if (!$dateTime instanceof \DateTime && !$dateTime instanceof \DateTimeInterface) {
         throw new TransformationFailedException('Expected a \\DateTime or \\DateTimeInterface.');
     }
     return $dateTime->getTimestamp();
 }
开发者ID:WilBenShu,项目名称:digital_pilot,代码行数:20,代码来源:DateTimeToTimestampTransformer.php

示例8: jsonSerialize

 /**
  * {@inheritdoc}
  */
 public function jsonSerialize()
 {
     $expires_at = null;
     if ($this->expires_at instanceof JsonSerializable) {
         $expires_at = $this->expires_at->jsonSerialize();
     } elseif ($this->expires_at instanceof DateTimeInterface) {
         $expires_at = $this->expires_at->getTimestamp();
     }
     return ['session_id' => $this->session_id, 'user_id' => $this->user_id, 'expires_at' => $expires_at];
 }
开发者ID:activecollab,项目名称:authentication,代码行数:13,代码来源:Session.php

示例9: getDateFormatted

 /**
  * @param string|\DateTimeInterface $date
  *
  * @return string
  */
 public function getDateFormatted($date) : string
 {
     if ($date instanceof \DateTimeInterface) {
         return $this->formatter->format($date->getTimestamp());
     } elseif (is_string($date)) {
         return $this->formatter->format(strtotime($date));
     } else {
         return '';
     }
 }
开发者ID:PHPinDD,项目名称:blog,代码行数:15,代码来源:DateFormatFilter.php

示例10: durationDiff

 /**
  * Returns the difference between two Period objects.
  *
  * @param \Thin\Period $period
  * @param bool                  $get_as_seconds If used and set to true, the method will return
  *                                              an intw hich represents the duration in seconds
  *                                              instead of a\DateInterval object
  *
  * @return \DateInterval|int
  */
 public function durationDiff(Period $period, $get_as_seconds = false)
 {
     $diff = $this->end->getTimestamp() - $this->start->getTimestamp() - $period->end->getTimestamp() + $period->start->getTimestamp();
     if (!$get_as_seconds) {
         $res = new DateInterval('PT' . abs($diff) . 'S');
         if (0 > $diff) {
             $res->invert = 1;
         }
         return $res;
     }
     return $diff;
 }
开发者ID:schpill,项目名称:thin,代码行数:22,代码来源:Period.php

示例11: transform

 /**
  * Transforms a normalized date into a localized date string/array.
  *
  * @param \DateTimeInterface $dateTime A DateTimeInterface object
  *
  * @return string|array Localized date string/array
  *
  * @throws TransformationFailedException If the given value is not a \DateTimeInterface
  *                                       or if the date could not be transformed.
  */
 public function transform($dateTime)
 {
     if (null === $dateTime) {
         return '';
     }
     if (!$dateTime instanceof \DateTimeInterface) {
         throw new TransformationFailedException('Expected a \\DateTimeInterface.');
     }
     $value = $this->getIntlDateFormatter()->format($dateTime->getTimestamp());
     if (intl_get_error_code() != 0) {
         throw new TransformationFailedException(intl_get_error_message());
     }
     return $value;
 }
开发者ID:sgrodzicki,项目名称:symfony,代码行数:24,代码来源:DateTimeToLocalizedStringTransformer.php

示例12: __construct

 /**
  * Created a timer event subscription backed by a scheduled job.
  * 
  * @param \DateTimeInterface $time Schedule date.
  * @param VirtualExecution $execution Target execution.
  * @param string $activityId ID of the activity that created the event subscription.
  * @param Node $node Target node to receive the delegated signal or NULL in order to use the activity node.
  * @param boolean $boundaryEvent Is this a subscription for a boundary event?
  */
 public function __construct(\DateTimeInterface $time, VirtualExecution $execution, $activityId, Node $node = NULL, $boundaryEvent = false)
 {
     parent::__construct('timer', $execution, $activityId, $node, $boundaryEvent);
     $this->time = $time->getTimestamp();
 }
开发者ID:Lesspion,项目名称:bpmn,代码行数:14,代码来源:CreateTimerSubscriptionCommand.php

示例13: computeExpires

 protected function computeExpires(\DateTimeInterface $expires = NULL)
 {
     // TODO: Lock min / max timeouts must be configurable.
     $min = new \DateTimeImmutable('+2 minutes');
     if ($expires === NULL || $expires < $min) {
         return $min;
     }
     $max = new \DateTimeImmutable('+2 hours');
     if ($expires > $max) {
         return $max;
     }
     return new \DateTimeImmutable('@' . $expires->getTimestamp(), $expires->getTimezone());
 }
开发者ID:koolkode,项目名称:webdav,代码行数:13,代码来源:DatabaseStorage.php

示例14: setExpires

 public function setExpires(\DateTimeInterface $expires)
 {
     $this->expires = new \DateTimeImmutable('@' . $expires->getTimestamp(), $expires->getTimezone());
 }
开发者ID:koolkode,项目名称:webdav,代码行数:4,代码来源:LockInfo.php

示例15: receiveDueCommands

 public function receiveDueCommands(\DateTimeInterface $now, int $limit = SchedulerWorker::DEFAULT_THROTTLE, \DateTimeInterface $startTime = null) : array
 {
     if ($startTime === null) {
         $start = 0;
     } else {
         $start = $startTime->getTimestamp();
     }
     $results = $this->evalScript('receive_due_messages', [$this->namespace, $start, $now->getTimestamp(), $limit]);
     $commands = [];
     foreach ($results as $result) {
         list($queueName, $id, $message, $score) = $result;
         $commands[] = new ReceivedScheduledCommand($queueName, $id, $message, new \DateTimeImmutable('@' . $score));
     }
     return $commands;
 }
开发者ID:mgdigital,项目名称:busque,代码行数:15,代码来源:RedisDriver.php


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