On shell I tried on test db
post = {"title" : "My Blog Post", "content" : "Here's my blog post.", ... "date" : new Date()}
but when I tried to retrieve it using command
db.blog.find();
its giving me output
{ "_id" : ObjectId("4f13fdc4af1aaf90a686f8ae"), "title" : "My Blog Post", "content" : "Here's my blog post.", "date" : ISODate("2012-01-16T10:35:54.985Z") }
why its showing date as ISODate?? Can I not save date just what new Date() is return in js?
ISODate is the shell’s helper function to wrap javascript’s Date constructor. Calling
ISODate()andnew Date()should produce the exact same Date object, it will just be printed differently.but:
however if you use the exact same millisecond to construct them then they are equal: