You are here

public static function TimestampUtils::dateDbToStr in Node expire 7.2

Convert timestamp int to date string.

Parameters

int $date_in: Timestamp (int) date representation for DB: not set, timestamp int.

object $ntype: Node expire configuration for particular node type.

Return value

string String date representation for UI: date string or ''.

2 calls to TimestampUtils::dateDbToStr()
FormHookHandler::doFormAlter in src/Module/Hook/FormHookHandler.php
Implements hook_form_alter().
NodeHookHandler::doNodeLoad in src/Module/Hook/NodeHookHandler.php
Implements hook_node_load().

File

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

Class

TimestampUtils
TimestampUtils class.

Namespace

Drupal\node_expire\Module\Utils

Code

public static function dateDbToStr($date_in, $ntype) {
  $date_inner = $date_in;
  if (empty($date_inner) || !TimestampHelper::isValidTimestamp($date_inner)) {
    if (isset($ntype) && !empty($ntype['default'])) {
      $default = $ntype['default'];
      $date_out = self::dateStrFromCfgDefault($default, FALSE);
    }
    else {
      $date_out = '';
    }
  }
  elseif ($date_inner >= NODE_EXPIRE_NO_EXPIRE) {
    $date_out = '';
  }
  else {

    // $date_out = date(ConfigHandler::getDateFormat(), $date_inner);
    $date_out = self::timestampToStr($date_inner);
  }
  return $date_out;
}