public static function Utilities::xsDateTimeToTimestamp in SAML SP 2.0 Single Sign On (SSO) - SAML Service Provider 7
3 calls to Utilities::xsDateTimeToTimestamp()
- SAML2_Assertion::parseAuthnStatement in includes/
Assertion.php - Parse AuthnStatement in assertion.
- SAML2_Assertion::parseConditions in includes/
Assertion.php - Parse conditions in assertion.
- SAML2_Assertion::__construct in includes/
Assertion.php
File
- includes/
Utilities.php, line 730
Class
- Utilities
- This file is part of miniOrange SAML plugin.
Code
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: " . $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;
}