MongoDB\BSON\UTCDateTime::toDateTimeImmutable
(mongodb >=1.20.0)
MongoDB\BSON\UTCDateTime::toDateTimeImmutable — Returns the DateTimeImmutable representation of this UTCDateTime
说明
参数
此函数没有参数。
返回值
Returns the DateTimeImmutable representation of this UTCDateTime. The returned DateTimeImmutable will use the UTC time zone.
错误/异常
- Throws MongoDB\Driver\Exception\InvalidArgumentException on argument parsing errors.
示例
示例 #1 MongoDB\BSON\UTCDatetime::toDateTimeImmutable() example
<?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" }
参见
- MongoDB\BSON\UTCDateTime::toDateTime() - Returns the DateTime representation of this UTCDateTime
- » BSON Types: Date
+添加备注
用户贡献的备注
此页面尚无用户贡献的备注。
备份地址:http://www.lvesu.com/blog/php/mongodb-bson-utcdatetime.todatetimeimmutable.php