DateTime::getTimezone
DateTimeImmutable::getTimezone
DateTimeInterface::getTimezone
date_timezone_get
(PHP 5 >= 5.2.0)
DateTime::getTimezone -- DateTimeImmutable::getTimezone -- DateTimeInterface::getTimezone -- date_timezone_get — Return time zone relative to given DateTime
Descrierea
Stil obiect-orientat
Stil procedural
Return time zone relative to given DateTime.
Parametri
-
object -
Doar pentru stilul procedural: Un obiect DateTime întors de funcția date_create()
Valorile întoarse
Returns a DateTimeZone object on success
sau FALSE în cazul eșecului.
Exemple
Example #1 DateTime::getTimezone() example
Stil obiect-orientat
<?php
$date = new DateTime(null, new DateTimeZone('Europe/London'));
$tz = $date->getTimezone();
echo $tz->getName();
?>
Stil procedural
<?php
$date = date_create(null, timezone_open('Europe/London'));
$tz = date_timezone_get($date);
echo timezone_name_get($tz);
?>
Exemplele de mai sus vor afișa:
Europe/London
Vedeți de asemenea
- DateTime::setTimezone() - Sets the time zone for the DateTime object
There are no user contributed notes for this page.
