Inserting ISODate type objects into MongoDB


There seems to be a problem when attempting to insert dates through the MongoDB Rest API, both in the API docs and in a PHP script, where using either ‘new Date()’ or ‘ISODate(“yyyy-mm-ddThh:MM:ss.SSSZ”)’ results in ‘No record(s) detected in request.’

Using just the correctly formatted date (e.g. “2014-01-10T10:10:10.000Z”) as suggested Inserting usable timestamps in Mongo does not work either, as it is not converted into the ISODate format, and so fails the Mongo validation on the collection (which requires {$type:“date”}).

Is it possible to insert a record with an ISODate field using PHP?