當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。