(mongodb >=1.20.0)
MongoDB\BSON\UTCDateTime::toDateTimeImmutable — 傳回此 UTCDateTime 的 DateTimeImmutable 表示法
此函式沒有參數。
傳回此 UTCDateTime 的 DateTimeImmutable 表示法。傳回的 DateTimeImmutable 將使用 UTC 時區。
範例 #1 MongoDB\BSON\UTCDatetime::toDateTimeImmutable() 範例
<?php
$utcdatetime = new MongoDB\BSON\UTCDateTime(1416445411987);
$datetime = $utcdatetime->toDateTimeImmutable();
var_dump($datetime->format('r'));
var_dump($datetime->format('U.u'));
var_dump($datetime->getTimezone());
?>
上述範例的輸出會類似於
string(31) "Thu, 20 Nov 2014 01:03:31 +0000" string(17) "1416445411.987000" object(DateTimeZone)#3 (2) { ["timezone_type"]=> int(1) ["timezone"]=> string(6) "+00:00" }