PHP 8.5.0 Alpha 1 available for testing

IntlDateFormatter::getTimeZone

datefmt_get_timezone

(PHP 5 >= 5.5.0, PHP 7, PHP 8, PECL intl >= 3.0.0)

IntlDateFormatter::getTimeZone -- datefmt_get_timezoneObtiene el formateador del huso horario

Descripción

Estilo orientado a objetos

public IntlDateFormatter::getTimeZone(): IntlTimeZone|false

Estilo por procedimientos

datefmt_get_timezone(IntlDateFormatter $formatter): IntlTimeZone|false

Devuelve un objeto IntlTimeZone que representa el huso horario utilizado por este objeto para formatear fechas y horas. Al formatear objetos IntlCalendar y DateTime con este IntlDateFormatter, el huso horario utilizado será devuelto por este método, y no aquel asociado con los objetos formateados.

Parámetros

Esta función no tiene parámetros.

Valores devueltos

El objeto IntlTimeZone asociado o false en caso de error.

Ejemplos

Ejemplo #1 Ejemplo con IntlDateFormatter::getTimeZone()

<?php

$madrid
= IntlDateFormatter::create(NULL, NULL, NULL, 'Europe/Madrid');
$lisbon = IntlDateFormatter::create(NULL, NULL, NULL, 'Europe/Lisbon');

var_dump($madrid->getTimezone());
echo
$madrid->getTimezone()->getDisplayName(
false, IntlTimeZone::DISPLAY_GENERIC_LOCATION, "en_US"), "\n";
echo
$lisbon->getTimeZone()->getId(), "\n";
// El identificador también puede ser obtenido con ->getTimezoneId()
echo $lisbon->getTimeZoneId(), "\n";

El resultado del ejemplo sería:

object(IntlTimeZone)#4 (4) {
  ["valid"]=>
  bool(true)
  ["id"]=>
  string(13) "Europe/Madrid"
  ["rawOffset"]=>
  int(3600000)
  ["currentOffset"]=>
  int(7200000)
}
Spain Time
Europe/Lisbon
Europe/Lisbon

Ver también

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top