the getTimestamp() function and the format("U") function for get the timestamp from a DateTime object, first convert the object in UTC TimeZone, and then give the timestamp int.
(PHP 5 >= 5.2.1, PHP 7)
DateTime::getTimezone -- DateTimeImmutable::getTimezone -- DateTimeInterface::getTimezone -- date_timezone_get — Return time zone relative to given DateTime
Stil obiect-orientat
Stil procedural
Return time zone relative to given DateTime.
object
Doar pentru stilul procedural: Un obiect DateTime întors de funcția date_create()
Returns a DateTimeZone object on success
sau false
în cazul eșecului.
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
the getTimestamp() function and the format("U") function for get the timestamp from a DateTime object, first convert the object in UTC TimeZone, and then give the timestamp int.