timezone_name_from_abbr

FunctionParams and return types changed in PHP 8.0

Returns a timezone name by guessing from abbreviation and UTC offset.

PHP 5
PHP 7
PHP 8.0
Improved
PHP 8.1
PHP 8.2-8.3
PHP 8.4
PHP 8.5
PHP 8.6

timezone_name_from_abbr Function synopsis

timezone_name_from_abbr(
    string $abbr,
    int $utcOffset = -1,
    int $isDST = -1
  ): string|false

Parameters

$abbr

Typestring

Time zone abbreviation.

$utcOffset

OptionalTypeintDefault value-1

Offset from GMT in seconds. Defaults to -1 which means that first found time zone corresponding to $abbr is returned. Otherwise exact offset is searched and only if not found then the first time zone with any offset is returned.

$isDST

OptionalTypeintDefault value-1

Daylight saving time indicator. Defaults to -1, which means that whether the time zone has daylight saving or not is not taken into consideration when searching. If this is set to 1, then the $utcOffset is assumed to be an offset with daylight saving in effect; if 0, then $utcOffset is assumed to be an offset without daylight saving in effect. If $abbr doesn't exist then the time zone is searched solely by the $utcOffset and $isDST.

Return value

Typestring|false

Returns time zone name on success or false on failure.

Changes to the timezone_name_from_abbr Function

PHP 8.0

  • Return type added: string|false
  • Parameter type added for parameter #1 ($abbr): string
  • Parameter name of parameter #2 changed: $gmtoffset to $utcOffset
  • Parameter type added for parameter #2 ($utcOffset): int
  • Parameter default value added for position #2 ($utcOffset): -1
  • Parameter name of parameter #3 changed: $isdst to $isDST
  • Parameter type added for parameter #3 ($isDST): int
  • Parameter default value added for position #3 ($isDST): -1
  timezone_name_from_abbr(
-     $abbr,
+     string $abbr,
-     $gmtoffset,
+     int $utcOffset = -1,
-     $isdst
+     int $isDST = -1
-   )
+   ): string|false

timezone_name_from_abbr Function Availability

PHP VersionAvailability
PHP 8.6Upcoming Release Yes
PHP 8.5Supported (Latest) Yes
PHP 8.4Supported Yes
PHP 8.3Security-Fixes Only Yes
PHP 8.2Security-Fixes Only Yes
PHP 8.1Unsupported Yes
PHP 8.0Unsupported Yes
PHP 7.4Unsupported Yes
PHP 7.3Unsupported Yes
PHP 7.2Unsupported Yes
PHP 7.1Unsupported Yes
PHP 7.0Unsupported Yes
PHP 5.6Unsupported Yes
PHP 5.5Unsupported Yes
PHP 5.4Unsupported Yes
PHP 5.3Unsupported Yes