简体   繁体   中英

Mongoose - How to read and compare mongoose createdAt timestamp

Mongoose timestamp option restore createdAt information like 2017-12-10T04:22:43.660Z which I can't read into Date . What should I do to this information so that I can compare two timestamps to determine which one is created ealier.

Try using Date.Parse("put the timestamp here") it should work. If not, try to define the time format and then parse it out. That will work.

Example of usage: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM