First : npm install mongoose-timestamp
Next: let Timestamps = require('mongoose-timestamp')
Next: let MySchema = new Schema
Next: MySchema.plugin(Timestamps)
Next : const Collection = mongoose.model('Collection',MySchema)
Then you can use the Collection.createdAt
or Collection.updatedAt
anywhere your want.
Created on: Date Of The Week Month Date Year 00:00:00 GMT
Time is in this format.