public static function TimestampUtils::stringToTimestampAdv in Node expire 7.2
Converts string to timestamp with interval option checking.
File
- src/
Module/ Utils/ TimestampUtils.php, line 212 - TimestampUtils class.
Class
- TimestampUtils
- TimestampUtils class.
Namespace
Drupal\node_expire\Module\UtilsCode
public static function stringToTimestampAdv($format, $str) {
$dt = \DateTime::createFromFormat('!' . $format, $str);
if (!$dt) {
// Try if string is an interval.
$dt = new \DateTime();
$dt
->modify($str);
if (!$dt) {
throw new ExpireException(t('Wrong datetime/interval string.'));
}
}
$timestamp = $dt
->getTimestamp();
return $timestamp;
}