You are here

public static function TimestampUtils::dateStrToCfgDefault in Node expire 7.2

Converts date string to timestamp int.

NODE_EXPIRE_NO_EXPIRE and '' are used as special values. Intervals are accepted as well.

1 call to TimestampUtils::dateStrToCfgDefault()
FormHookHelper::doFormNodeTypeFormAlterSubmit in src/Module/Hook/FormHookHelper.php
Implements hook_form_alter().

File

src/Module/Utils/TimestampUtils.php, line 137
TimestampUtils class.

Class

TimestampUtils
TimestampUtils class.

Namespace

Drupal\node_expire\Module\Utils

Code

public static function dateStrToCfgDefault($date_in) {
  if (!isset($date_in)) {
    $date_out = '';
    return $date_out;
  }
  $date_inner = trim($date_in);
  if (empty($date_inner)) {
    $date_out = '';
    return $date_out;
  }
  elseif (TimestampHelper::isInterval($date_inner)) {
    return $date_inner;
  }

  // Try to handle as timestamp.
  try {
    $format = ConfigHandler::getDateFormat();
    $timestamp = TimestampHelper::stringToTimestamp($format, $date_inner);
    return $timestamp;
  } catch (\Exception $e) {
    $date_out = '';
    return $date_out;
  }
}