You are here

public static function DatexFormatter::getTzObject in Datex 7

Returns a valid timezone object from given timezone.

Returns $tz itself if it is already a DateTimeZone object.

8 calls to DatexFormatter::getTzObject()
DatexFormatter::formatPHP in datex_api/datex_api_classes.inc
Formats a date according to format given.
DatexFormatter::getTzString in datex_api/datex_api_classes.inc
Returns a valid timezone string from given timezone.
DatexObject::setDate in datex_api/datex_api_classes.inc
Sets date and time zone.
DatexObject::setDatetime in datex_api/datex_api_classes.inc
Set's date from given date.
DatexObject::setTimezone in datex_api/datex_api_classes.inc
Sets Time Zone of internal date object.

... See full list

File

datex_api/datex_api_classes.inc, line 466
API and helper functions used by other datex modules.

Class

DatexFormatter
Date tools for Jalali Dates.

Code

public static function getTzObject($tz = NULL) {
  if ($tz) {
    if (is_string($tz)) {
      $tz = new DateTimeZone($tz);
    }
    elseif (!$tz instanceof DateTimeZone) {
      $tz = new DateTimeZone(date_default_timezone_get());
    }
  }
  return $tz;
}