MongoDB\BSON\UTCDateTime::toDateTimeImmutable
PHP function
Edit on GitHub ✎
(mongodb >=1.20.0)
Returns the DateTimeImmutable representation of this UTCDateTime
Description
MongoDB\BSON\UTCDateTime::toDateTimeImmutable(): DateTimeImmutable
Parameters Parameters
Return Values
Returns the DateTimeImmutable representation of this UTCDateTime. The returned DateTimeImmutable will use the UTC time zone.
Errors/Exceptions
Examples
MongoDB\BSON\UTCDatetime::toDateTimeImmutable() example
php
<?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());
?>The above example will output something similar to:
output
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"
}See Also
MongoDB\BSON\UTCDateTime::toDateTime- BSON Types: Date