iT邦幫忙

0

請問如何找到PHP標準函式庫的class定義

php

目前我在解讀的程式碼部分

// 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

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

1
㊣浩瀚星空㊣
iT邦大神 1 級 ‧ 2020-09-14 09:15:38
最佳解答

DateTimeZone 算是由官網提供的一個物件。並不存在程式碼內。
你的確只能從官網內查使用方式。

johnqq iT邦新手 5 級 ‧ 2020-09-14 11:26:49 檢舉

感謝你

我要發表回答

立即登入回答