Home > Net >  Changing date.now in mongoose schema to display date in this format" MMMM Do YYYY"
Changing date.now in mongoose schema to display date in this format" MMMM Do YYYY"

Time:09-23

How to I update the date.now in mongoose schema to show only the date in this format "MMMM Do YYYY" the mongoose schema

date: {
    type: Date,
    default: Date.now,
},

the format i get in the database

date: 2021-09-21T13:02:49.856 00:00

how to i remove the T13:02:49.856 00:00 and change the format to "MMMM Do YYYY"

CodePudding user response:

You could extract the date first, using date.slice(0,10) on your date: 2021-09-21T13:02:49.856 00:00.Then you may want to convert it using a handy time-dealing library, like Luxon.

  • Related