src/Repository/DoctrineMongoODM/Types/TimezoneAwareDate.php
public function convertToDatabaseValue($value)
    {
        if (!$value instanceof \DateTime) {
            return null;
        }
        
        $timezone  = $value->getTimezone()->getName();
        $timestamp = $value->getTimestamp();
        $date      = new \MongoDate($timestamp);
        
        return array(
            'date' => $date,
            'tz'   => $timezone,
        );
    }
public function convertToDatabaseValue($value)
    {
        if (!$value instanceof \DateTime) {
            return null;
        }
        
        $timezone  = $value->getTimezone()->getName();
        $timestamp = $value->getTimestamp();
        $date      = new \MongoDate($timestamp);
        
        return array(
            'date' => $date,
            'tz'   => $timezone,
        );
    }
public function convertToDatabaseValue ( $ value ) { if ( ! $ value instanceof \ DateTime ) { return null ; } $ timezone = $ value -> getTimezone ( ) -> getName ( ) ; $ timestamp = $ value -> getTimestamp ( ) ; $ date = new \ MongoDate ( $ timestamp ) ; return array ( 'date' => $ date , 'tz' => $ timezone , ) ; }
Converts a \DateTime object to MongoDB representation.

If <code>$value</code> is <i>NULL</i> (or not a \DateTime object),
nothing is done and <i>NULL</i> returned.

@internal
Resulting value is an array:
<pre>
array(
'date' => \MongoDate(\DateTime::timestamp),
'tz'   => TimeZone-Identifier (e.g. "Europe/Berlin")
)
</pre>

@param \DateTime|null $value
@return null|array
@see \Doctrine\ODM\MongoDB\Types\Type::convertToDatabaseValue()
Converts a \ DateTime object to MongoDB representation .