A pretty nifty way to not have to store an "added" key with a record - for example you may need to store when a user joined or w/e - normaly it would be with say "added" : (int)time()
You can save your RAM/Disk space by using getTimestamp(); in the following way
$ts=new MongoId('51547a02bb07f8d96f000723');
$added_epoch=$ts->getTimestamp();
//1364490754
Happy days :)
MongoId::getTimestamp
(PECL mongo >= 1.0.1)
MongoId::getTimestamp — Gets the number of seconds since the epoch that this id was created
Description
public int MongoId::getTimestamp
( void
)
This returns the same thing as running time() when the id is created.
Parameters
This function has no parameters.
Return Values
Returns the number of seconds since the epoch that this id was created. There are only four bytes of timestamp stored, so MongoDate is a better choice for storing exact or wide-ranging times.
alex at nodex dot co dot uk ¶
5 days ago
