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.0, PHP 7)
DateTime::getTimezone -- DateTimeImmutable::getTimezone -- DateTimeInterface::getTimezone -- date_timezone_get — Return time zone relative to given DateTime
객체 기반 형식
절차식 형식
Return time zone relative to given DateTime.
object
절차식 전용: date_create()가 반환하는 DateTime 객체.
Returns a DateTimeZone object on success
실패 시 FALSE
를 반환합니다.
Example #1 DateTime::getTimezone() example
객체 기반 형식
<?php
$date = new DateTime(null, new DateTimeZone('Europe/London'));
$tz = $date->getTimezone();
echo $tz->getName();
?>
절차식 형식
<?php
$date = date_create(null, timezone_open('Europe/London'));
$tz = date_timezone_get($date);
echo timezone_name_get($tz);
?>
위 예제들의 출력:
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.