Store and Retrieve Date in dd MMM yyyy format in MongoDB model
问题 I have a MongoDB model that contains a Date field whose type is defined as Date.now. Any date is converted to ISO date format. Inside the model the date is defined as : xDate : { type: Date.now, required: true } I pass the current Date as : var d = new Date(); var temp = d.toISOString(); var subStr = temp.substr(10,temp.length - 1); var curDate = temp.replace(subStr, "T00:00:00.000Z"); console.log(curDate); However the date is stored as an ISO String inside the MongoDB schema. I try to query