目前我在解讀的程式碼部分
// time zones
function getConvertedDateTimeObject($timestamp, $userTimezone)
{
# create server and user timezone objects
$fromZone = new DateTimeZone('UTC'); // UTC
$toZone = new DateTimeZone($userTimezone); // Europe/London, or whatever it happens to be
$time = date('Y-m-d H:i:s', $timestamp);
$dt = new DateTime($time, $fromZone);
$dt->setTimezone($toZone);
return $dt;
}
function getUserTimestamp($timestamp, $userTimezone)
{
$dt = $this->getConvertedDateTimeObject($timestamp, $userTimezone);
return $dt->getTimestamp();
}
function getUserOffset($timestamp, $userTimezone)
{
$dt = $this->getConvertedDateTimeObject($timestamp, $userTimezone);
return $dt->getOffset();
}
請問以上內容中的這段DateTimeZone('UTC'),getTimestamp(),getOffset()是不是來自php標準函式庫?
要如何從檔案中找到他的class?
還是只能從官網查class的使用方式?
$fromZone = new DateTimeZone('UTC'); // UTC
return $dt->getTimestamp();
return $dt->getOffset();
在官網找到
datetimezone
https://www.php.net/manual/en/class.datetimezone.php
gettimestamp
https://www.php.net/manual/en/datetime.gettimestamp.php
getoffset
https://www.php.net/manual/en/datetime.getoffset.php