You are here

function date_get_timezone in Date 8

Same name and namespace in other branches
  1. 5.2 date_api.module \date_get_timezone()
  2. 5 date.inc \date_get_timezone()
  3. 6.2 date_api.module \date_get_timezone()
  4. 6 date/date.module \date_get_timezone()
  5. 7.3 date_api/date_api.module \date_get_timezone()
  6. 7 date_api/date_api.module \date_get_timezone()
  7. 7.2 date_api/date_api.module \date_get_timezone()

Function to figure out which local timezone applies to a date and select it.

Parameters

string $handling: The timezone handling.

string $timezone: (optional) A timezone string. Defaults to an empty string.

Return value

string The timezone string.

16 calls to date_get_timezone()
DateFieldWidgetBase::formElement in date_field/lib/Drupal/date_field/Plugin/field/widget/DateFieldWidgetBase.php
Implements Drupal\field\Plugin\Type\Widget\WidgetInterface::formElement().
DateTextWidget::formElement in lib/Drupal/date/Plugin/field/widget/DateTextWidget.php
Implements Drupal\field\Plugin\Type\Widget\WidgetInterface::formElement().
DateWidgetBase::formElement in lib/Drupal/date/Plugin/field/widget/DateWidgetBase.php
Implements Drupal\field\Plugin\Type\Widget\WidgetInterface::formElement().
date_context_date_condition::execute in date_context/plugins/date_context_date_condition.inc
date_default_value in ./date.module
The callback for setting a default value for an empty date field.

... See full list

File

date_api/date_api.module, line 321
This module will make the date API available to other modules. Designed to provide a light but flexible assortment of functions and constants, with more functionality in additional files that are not loaded unless other modules specifically include them.

Code

function date_get_timezone($handling, $timezone = '') {
  switch ($handling) {
    case 'date':
      $timezone = !empty($timezone) ? $timezone : drupal_get_user_timezone();
      break;
    case 'utc':
      $timezone = 'UTC';
      break;
    default:
      $timezone = drupal_get_user_timezone();
  }
  return $timezone > '' ? $timezone : drupal_get_user_timezone();
}