MongoId::getTimestamp PHP Method

getTimestamp() public method

(PECL mongo >= 1.0.1) Gets the number of seconds since the epoch that this id was created
public getTimestamp ( ) : integer
return integer
    public function getTimestamp()
    {
        return hexdec(substr((string) $this->objectID, 0, 8));
    }

Usage Example

 public function testCreateWithString()
 {
     $original = '54203e08d51d4a1f868b456e';
     $id = new \MongoId($original);
     $this->assertSame($original, (string) $id);
     $this->assertSame(9127278, $id->getInc());
     $this->assertSame(1411399176, $id->getTimestamp());
     $this->assertSame(34335, $id->getPID());
 }
All Usage Examples Of MongoId::getTimestamp