简体   繁体   English

用PHP创建MongoDB集合的日期?

[英]MongoDB collection creation date with PHP?

I want to delete all mongodb collection before created date today with cron. 我想在今天用cron创建日期之前删除所有mongodb集合。 So i want MongoDB collection creation date. 所以我想要MongoDB集合的创建日期。 Can it possible to get data from database in php . 能否从php中的数据库获取数据。

However i have below option to get date manually. 但是我有以下选择手动获取日期。

I can create new collection that will contain collection name and create date. 我可以创建一个新集合,其中将包含集合名称和创建日期。

From object id you can get the date, so make use of it and delete accordingly. 您可以从对象ID获取日期,因此可以使用它并相应地删除它。

ObjectId is a 12-byte BSON type, constructed using: ObjectId是一种12字节的BSON类型,使用以下方式构造:

a 4-byte value representing the seconds since the Unix epoch,
a 3-byte machine identifier,
a 2-byte process id, and
a 3-byte counter, starting with a random value.

Please check thi link : http://docs.mongodb.org/manual/reference/object-id/ 请检查以下链接: http : //docs.mongodb.org/manual/reference/object-id/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM