DateTime::getTimezone

DateTimeImmutable::getTimezone

DateTimeInterface::getTimezone

date_timezone_get

(PHP 5 >= 5.2.1, PHP 7, PHP 8)

DateTime::getTimezone -- DateTimeImmutable::getTimezone -- DateTimeInterface::getTimezone -- date_timezone_getRetorna o fuso horário corresponde a um DateTime informado

Descrição

Estilo orientado a objetos

public DateTime::getTimezone(): DateTimeZone
public DateTimeImmutable::getTimezone(): DateTimeZone
public DateTimeInterface::getTimezone(): DateTimeZone

Estilo procedural

Retorna o fuso horário de um DateTime informado

Parâmetros

object

Somente no estilo procedural: Um objeto DateTime retornado por date_create()

Valor Retornado

Retorna um objeto DateTimeZone em caso de sucesso ou false em caso de falha.

Exemplos

Exemplo #1 Exemplo do método DateTime::getTimezone()

Estilo orientado a objetos

<?php
$date
= new DateTime(null, new DateTimeZone('Europe/London'));
$tz = $date->getTimezone();
echo
$tz->getName();
?>

Estilo procedural

<?php
$date
= date_create(null, timezone_open('Europe/London'));
$tz = date_timezone_get($date);
echo
timezone_name_get($tz);
?>

Os exemplos acima produzirão:

Europe/London

Veja Também

add a note

User Contributed Notes

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