public static function Utilities::xsDateTimeToTimestamp in SAML SP 2.0 Single Sign On (SSO) - SAML Service Provider 8
3 calls to Utilities::xsDateTimeToTimestamp()
- SAML2_Assertion::parseAuthnStatement in src/SAML2_Assertion.php 
- Parse AuthnStatement in assertion.
- SAML2_Assertion::parseConditions in src/SAML2_Assertion.php 
- Parse conditions in assertion.
- SAML2_Assertion::__construct in src/SAML2_Assertion.php 
File
- src/Utilities.php, line 328 
Class
- Utilities
- This file is part of miniOrange SAML plugin.
Namespace
Drupal\miniorange_samlCode
public static function xsDateTimeToTimestamp($time) {
  $matches = array();
  // We use a very strict regex to parse the timestamp.
  $regex = '/^(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)T(\\d\\d):(\\d\\d):(\\d\\d)(?:\\.\\d+)?Z$/D';
  if (preg_match($regex, $time, $matches) == 0) {
    echo sprintf("invalid SAML2 timestamp passed to xsDateTimeToTimestamp " . Xss::filter($time));
    // exit;
  }
  // Extract the different components of the time from the  matches in the regex.
  // intval will ignore leading zeroes in the string.
  $year = intval($matches[1]);
  $month = intval($matches[2]);
  $day = intval($matches[3]);
  $hour = intval($matches[4]);
  $minute = intval($matches[5]);
  $second = intval($matches[6]);
  // We use gmmktime because the timestamp will always be given
  //in UTC.
  $ts = gmmktime($hour, $minute, $second, $month, $day, $year);
  return $ts;
}