public function toDateTime()
    {
        $datetime = new \DateTime();
        $datetime->setTimestamp($this->sec);

        $microSeconds = $this->truncateMicroSeconds($this->usec);
        if ($microSeconds > 0) {
            $datetime = \DateTime::createFromFormat('Y-m-d H:i:s.u', $datetime->format('Y-m-d H:i:s') . '.' . str_pad($microSeconds, 6, '0', STR_PAD_LEFT));
        }

        $datetime->setTimezone(new \DateTimeZone("UTC"));

        return $datetime;
    }
public function toDateTime()
    {
        $datetime = new \DateTime();
        $datetime->setTimestamp($this->sec);

        $microSeconds = $this->truncateMicroSeconds($this->usec);
        if ($microSeconds > 0) {
            $datetime = \DateTime::createFromFormat('Y-m-d H:i:s.u', $datetime->format('Y-m-d H:i:s') . '.' . str_pad($microSeconds, 6, '0', STR_PAD_LEFT));
        }

        $datetime->setTimezone(new \DateTimeZone("UTC"));

        return $datetime;
    }
public function toDateTime ( ) { $ datetime = new \ DateTime ( ) ; $ datetime -> setTimestamp ( $ this -> sec ) ; $ microSeconds = $ this -> truncateMicroSeconds ( $ this -> usec ) ; if ( $ microSeconds > 0 ) { $ datetime = \ DateTime :: createFromFormat ( 'Y-m-d H:i:s.u' , $ datetime -> format ( 'Y-m-d H:i:s' ) . '.' . str_pad ( $ microSeconds , 6 , '0' , STR_PAD_LEFT ) ) ; } $ datetime -> setTimezone ( new \ DateTimeZone ( "UTC" ) ) ; return $ datetime ; }
Returns a DateTime object representing this date
@link http://php.net/manual/en/mongodate.todatetime.php
@return DateTime
Returns a DateTime object representing this date