Reputation: 1712
I'm receiving some JSON files through a git repo I need to feed into a database.
Is there any command line script/utility so I can convert every date in the json fields from ISO 8601 (example: 2014-11-18T23:00:00.000Z
) to its timestamp/unix epoch equivalent?
Upvotes: 0
Views: 340
Reputation: 934
This is what I used to go from timestamp to ISODate, hope you find this helpful to get what you want.
/usr/bin/mongo mydb --eval
"db.collection.find().forEach(function(doc){
doc.timestamp = new ISODate(new Date(doc.timestamp).toISOString());
db.collection.save(doc)
});"
Also, use this. Good luck!
Upvotes: 2