Components/DB/NoSQL/Drivers/MongoDB/MongoDBDateHandler.php
public function convertFromMongoFormatToDateTime(VisitorInterface $visitor, $date, array $type, Context $context)
    {
        /**
         * this $dateTime object is incorrect in case of using microseconds
         * because after conversion of \MongoDB\BSON\UTCDateTime to \DateTime
         * method $dateTime->format('U.u') returns invalid string xxxxxxxxx.zzzzzzzzz
         * part after "." contains 9 digits but it should contain up to 6 digits
         * so we have to reduce this part to 6 digits.
         *
         * @var \DateTime
         */
        if (!is_string($date) && !$date instanceof UTCDatetime) {
            throw new \InvalidArgumentException('The provided date must be a valid string or an instance of UTCDateTime');
        }

        if (is_string($date)) {
            $dateTime = date_create($date);
            if (false === $dateTime) {
                throw new \InvalidArgumentException(sprintf('The provided date "%s" is not a valid date/time string', $date));
            }

            return $dateTime;
        }

        return self::convertMongoFormatToDateTime($date);
    }
public function convertFromMongoFormatToDateTime(VisitorInterface $visitor, $date, array $type, Context $context)
    {
        /**
         * this $dateTime object is incorrect in case of using microseconds
         * because after conversion of \MongoDB\BSON\UTCDateTime to \DateTime
         * method $dateTime->format('U.u') returns invalid string xxxxxxxxx.zzzzzzzzz
         * part after "." contains 9 digits but it should contain up to 6 digits
         * so we have to reduce this part to 6 digits.
         *
         * @var \DateTime
         */
        if (!is_string($date) && !$date instanceof UTCDatetime) {
            throw new \InvalidArgumentException('The provided date must be a valid string or an instance of UTCDateTime');
        }

        if (is_string($date)) {
            $dateTime = date_create($date);
            if (false === $dateTime) {
                throw new \InvalidArgumentException(sprintf('The provided date "%s" is not a valid date/time string', $date));
            }

            return $dateTime;
        }

        return self::convertMongoFormatToDateTime($date);
    }
public function convertFromMongoFormatToDateTime ( VisitorInterface $ visitor , $ date , array $ type , Context $ context ) { /**
         * this $dateTime object is incorrect in case of using microseconds
         * because after conversion of \MongoDB\BSON\UTCDateTime to \DateTime
         * method $dateTime->format('U.u') returns invalid string xxxxxxxxx.zzzzzzzzz
         * part after "." contains 9 digits but it should contain up to 6 digits
         * so we have to reduce this part to 6 digits.
         *
         * @var \DateTime
         */ if ( ! is_string ( $ date ) && ! $ date instanceof UTCDatetime ) { throw new \ InvalidArgumentException ( 'The provided date must be a valid string or an instance of UTCDateTime' ) ; } if ( is_string ( $ date ) ) { $ dateTime = date_create ( $ date ) ; if ( false === $ dateTime ) { throw new \ InvalidArgumentException ( sprintf ( 'The provided date "%s" is not a valid date/time string' , $ date ) ) ; } return $ dateTime ; } return self :: convertMongoFormatToDateTime ( $ date ) ; }
Method converts \MongoDB\BSON\UTCDateTime to \DateTime.

@param VisitorInterface $visitor
@param UTCDatetime      $date
@param array            $type
@param Context          $context

@return \DateTime
Method converts \ MongoDB \ BSON \ UTCDateTime to \ DateTime .