Definition定义
ObjectId.getTimestamp()Returns the timestamp portion of the将ObjectId()as a Date.ObjectId()的时间戳部分作为Date返回。
Compatibility兼容性
This method is available in deployments hosted in the following environments:此方法在以下环境中托管的部署中可用:
- MongoDB Atlas
: The fully managed service for MongoDB deployments in the cloud:云中MongoDB部署的完全托管服务
- MongoDB Enterprise
: The subscription-based, self-managed version of MongoDB:MongoDB的基于订阅的自我管理版本 - MongoDB Community
: The source-available, free-to-use, and self-managed version of MongoDB:MongoDB的源代码可用、免费使用和自我管理版本
Example示例
The following example calls the 以下示例调用getTimestamp() method on an ObjectId():ObjectId()上的getTimestamp()方法:
ObjectId("507c7f79bcf86cd7994f6c0e").getTimestamp()
This will return the following output:这将返回以下输出:
ISODate("2012-10-15T21:26:17Z")