- PHP 手册
- 函数参考
- 数据库扩展
- 针对各数据库系统对应的扩展
- Mongo
- Types
- MongoId
MongoId::getTimestamp
(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.
说明
public MongoId::getTimestamp ( void ) : int返回 id 创建时运行 time() 同样的东西。
参数
此函数没有参数。
返回值
获取新纪元时间到 id 创建时的秒数。 仅储存了四个字节的时间戳,所以 MongoDate 是储存更精准、更广范围时间的更佳选择。
User Contributed Notes 2 notes
up down 0 Anonymous ¶2 years ago
see http://php.net/manual/en/mongodb-bson-objectid.gettimestamp.php
up
down
0
le6o ¶2 years ago
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));
?>
add a note
官方地址:https://www.php.net/manual/en/mongoid.gettimestamp.php