downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

MongoId::__set_state> <MongoId::getPID
[edit] Last updated: Tue, 21 May 2013

view this page in

MongoId::getTimestamp

(PECL mongo >= 1.0.1)

MongoId::getTimestampGets 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.



add a note add a note User Contributed Notes MongoId::getTimestamp - [1 notes]
up
0
alex at nodex dot co dot uk
7 days ago
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 :)

 
show source | credits | sitemap | contact | advertising | mirror sites