(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"
}