You are here

function date_jscalendar_make_dbdate in Date 5

Construct a value to save to the database from jscalendar input

Parameters

$value - a text value created by js_calendar: @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_jscalendar_make_dbdate'
date_widget in ./date.module
Implementation of hook_widget().

File

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

Code

function date_jscalendar_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_custom2unix($value, $format);
      break;
    case DATE_ISO:
      $value = date_custom2iso($value, $format);
      break;
  }
  if ($value) {
    if ($date = date_make_date($value, $timezone_in, 'local', $type)) {
      return $date;
    }
  }
  return FALSE;
}