Quick Snippet: get creation time from id on MongoDB
This can be useful to someone: you can get the creation time from a Mongo ObjectId, simply by looking at the first four bytes of the id. PHP example:
$creation_date = date(‘Y-m-d H:i:s’, hexdec(substr($id, 0, 8)));
You can also use MongoId::getTimestamp method from Mongo PHP driver, if it’s loaded :-)
September 27, 2011