nitin jain
nitin jain

Reputation: 298

MongoDB collection creation date with PHP?

I want to delete all mongodb collection before created date today with cron. So i want MongoDB collection creation date. Can it possible to get data from database in php .

However i have below option to get date manually.

I can create new collection that will contain collection name and create date.

Upvotes: 0

Views: 122

Answers (1)

Prasanth Bendra
Prasanth Bendra

Reputation: 32810

From object id you can get the date, so make use of it and delete accordingly.

ObjectId is a 12-byte BSON type, constructed using:

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/

Upvotes: 1

Related Questions