MongoDate::toDateTime

Returns a DateTime object representing this date

注意:

このメソッドを定義している拡張モジュールは非推奨です。 かわりに MongoDB 拡張モジュールを使うべきです。 このメソッドの代替として、以下が使えます。

  • MongoDB\BSON\UTCDateTime::toDateTime

説明

public DateTime MongoDate::toDateTime ( void )

Returns the DateTime representation of this date. The returned DateTime will use the UTC time zone.

パラメータ

この関数にはパラメータはありません。

返り値

This date as a DateTime object.

例1 MongoDate::toDateTime example

This example demonstrates creating a DateTime object from a MongoDate object.

<?php
$d 
= new MongoDate(strtotime("2014-11-18 11:01:25"));
var_dump$d->toDateTime() );
?>

上の例の出力は、 たとえば以下のようになります。

class DateTime#2 (3) {
  public $date =>
  string(26) "2014-11-18 11:01:25.000000"
  public $timezone_type =>
  int(1)
  public $timezone =>
  string(6) "+00:00"
}