How do I get ISO date from database MongoDB..?


#1

Hiii Friends,

My date store ISODate(“2018-03-05T07:01:45.929Z”) this format. Now I want to match this value in database. How can I match this value from database…?


#2

Just use it as it is:

db.users.findOne({createdAt: ISODate(“2018-03-05T07:01:45.929Z”)})

If you need an object with that format:

var t = new Date(2018, 2, 5, 7, 1, 45, 929).toISOString()
// ISODate(“2018-03-05T07:01:45.929Z”)

Note: The argument month is 0-based. This means that January = 0 and December = 11.