You are here

function webform_date_format in Webform 6.3

Same name and namespace in other branches
  1. 5.2 components/date.inc \webform_date_format()
  2. 6.2 components/date.inc \webform_date_format()
  3. 7.4 webform.module \webform_date_format()
  4. 7.3 webform.module \webform_date_format()

Get a date format according to the site settings.

Parameters

$size: A choice of 'short', 'medium', or 'long' date formats.

6 calls to webform_date_format()
theme_webform_display_date in components/date.inc
Format the text output for this component.
theme_webform_results_download_range in includes/webform.report.inc
Theme the output of the export range fieldset.
webform_validate_date in components/date.inc
Element validation for Webform date fields.
_webform_csv_data_date in components/date.inc
Implements _webform_csv_data_component().
_webform_filter_values in ./webform.module
Filters all special tokens provided by webform, such as %post and %profile.

... See full list

File

./webform.module, line 3539

Code

function webform_date_format($size = 'medium') {

  // Format date according to site's given format.
  $format = variable_get('date_format_' . $size, 'D, m/d/Y - H:i');
  $time = 'aABgGhHisueIOPTZ';
  $day_of_week = 'Dlw';
  $special = ',-: ';
  $date_format = trim($format, $time . $day_of_week . $special);

  // Ensure that a day, month, and year value are present. Use a default
  // format if all the values are not found.
  if (!preg_match('/[dj]/', $date_format) || !preg_match('/[FmMn]/', $date_format) || !preg_match('/[oYy]/', $date_format)) {
    $date_format = 'm/d/Y';
  }
  return $date_format;
}