You are here

function date_text_make_dbdate in Date 5

Construct a value to save to the database from text input

Parameters

$value - string date value, could be iso format or text for strtotime conversion: @param $type - DATE_UNIX or DATE_ISO @param $format - a string containing the format the field is using (date() format) @param $timezone_in - timezone of supplied value @param $granularity = an array of date parts to be selected, like array('Y','M','D'), default is M, D, Y Y => year, M => month, D => day, H => hours, N => minutes, S => seconds, T => timezone

1 string reference to 'date_text_make_dbdate'
date_widget in ./date.module
Implementation of hook_widget().

File

./date.inc, line 1042
Date/time API functions

Code

function date_text_make_dbdate($value, $type, $format, $timezone_in = 'GMT', $granularity = array(
  'M',
  'D',
  'Y',
)) {
  $value = trim($value);
  if ($value == '') {
    return NULL;
  }
  switch ($type) {
    case DATE_UNIX:
      $value = date_text2unix($value, $format);
      break;
    case DATE_ISO:
      $value = date_text2iso($value, $format);
      break;
  }
  if ($value) {
    if ($date = date_make_date($value, $timezone_in, 'local', $type)) {
      return $date;
    }
  }
  return FALSE;
}