--TEST-- MongoDB\BSON\UTCDateTime #001 --SKIPIF-- --FILE-- insert(array('_id' => 1, 'x' => $utcdatetime)); $manager->executeBulkWrite(NS, $bulk); $query = new MongoDB\Driver\Query(array('_id' => 1)); $cursor = $manager->executeQuery(NS, $query); $results = iterator_to_array($cursor); $tests = array( array($utcdatetime), array($results[0]->x), ); foreach($tests as $n => $test) { $s = fromPHP($test); echo "Test#{$n} ", $json = toJSON($s), "\n"; $bson = fromJSON($json); $testagain = toPHP($bson); var_dump(toJSON(fromPHP($test)), toJSON(fromPHP($testagain))); var_dump((object)$test == (object)$testagain); } ?> ===DONE=== --EXPECT-- Test#0 { "0" : { "$date" : 1416445411987 } } string(37) "{ "0" : { "$date" : 1416445411987 } }" string(37) "{ "0" : { "$date" : 1416445411987 } }" bool(true) Test#1 { "0" : { "$date" : 1416445411987 } } string(37) "{ "0" : { "$date" : 1416445411987 } }" string(37) "{ "0" : { "$date" : 1416445411987 } }" bool(true) ===DONE===