You are here

function _node_expire_date_str_to_db in Node expire 7

Same name and namespace in other branches
  1. 8 node_expire.nodeapi.inc \_node_expire_date_str_to_db()

Convert date string to timestamp int.

Parameters

string $date_in: String date representation for UI: not set, non-date string, date string.

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

Return value

int Timestamp (int) date representation for DB: timestamp int, NODE_EXPIRE_NO_EXPIRE as a special value.

1 call to _node_expire_date_str_to_db()
_node_expire_node_update_insert in ./node_expire.nodeapi.inc
Implements hook_node_update() and hook_node_insert().

File

./node_expire.nodeapi.inc, line 339
Node API integration.

Code

function _node_expire_date_str_to_db($date_in, $ntype) {
  if (!isset($date_in)) {
    $date_out = NODE_EXPIRE_NO_EXPIRE;
    return $date_out;
  }
  $date_inner = trim($date_in);
  if (!strtotime($date_inner)) {

    // Make a valid date string.
    if (isset($ntype) && !empty($ntype->default) && strtotime($ntype->default)) {
      $date_inner = $ntype->default;
    }
    else {
      $date_out = NODE_EXPIRE_NO_EXPIRE;
      return $date_out;
    }
  }
  $date_out = strtotime($date_inner);
  return $date_out;
}