You are here

public function Verifier::getNow in Automatic Updates 8

Same name and namespace in other branches
  1. 7 vendor/drupal/php-signify/src/Verifier.php \Drupal\Signify\Verifier::getNow()

Gets a \DateTime object modeling "now".

Return value

\DateTime An object representing the current date in UTC for checking expiration.

1 call to Verifier::getNow()
Verifier::verifyCsigMessage in vendor/drupal/php-signify/src/Verifier.php
Verify a string message signed with CSIG chained-signature extended Signify format.

File

vendor/drupal/php-signify/src/Verifier.php, line 67

Class

Verifier

Namespace

Drupal\Signify

Code

public function getNow(\DateTime $now = NULL) {
  $date_format = 'Y-m-d';
  if (empty($now)) {
    $now = gmdate($date_format);
  }
  else {
    $now = $now
      ->format($date_format);
  }
  $now_dt = \DateTime::createFromFormat($date_format, $now, new \DateTimeZone('UTC'));
  if (!$now_dt instanceof \DateTime) {
    throw new VerifierException('Unexpected date format of current date.');
  }
  return $now_dt;
}