MongoDB\BSON\UTCDateTime::toDateTimeImmutable

(mongodb >=1.20.0)

MongoDB\BSON\UTCDateTime::toDateTimeImmutableRetorna a representação em DateTimeImmutable deste UTCDateTime

Descrição

final public MongoDB\BSON\UTCDateTime::toDateTimeImmutable(): DateTimeImmutable

Parâmetros

Esta função não possui parâmetros.

Valor Retornado

Retorna a representação em DateTimeImmutable deste UTCDateTime. O DateTimeImmutable retornado usará o fuso horário UTC.

Erros/Exceções

Exemplos

Exemplo #1 Exemplo de 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());

?>

O exemplo acima produzirá algo semelhante a:

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

Veja Também

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top