There is no equivalent for this method in the new extension, so instead use…
<?php
$id = new \MongoDB\BSON\ObjectID('42cf58a2e1c5ede216cb7f05');
$timestamp = hexdec(substr($id, 0, 8));
?>
(PECL mongo >= 1.0.1)
MongoId::getTimestamp — 获取新纪元时间到 id 创建时的秒数。
This extension that defines this method is deprecated. Instead, the MongoDB extension should be used. There is no equivalent for this method in the new extension.
此函数没有参数。
获取新纪元时间到 id 创建时的秒数。 仅储存了四个字节的时间戳,所以 MongoDate 是储存更精准、更广范围时间的更佳选择。