I want to display the date in the format "YYYY MM DD".
I have tried with expresss-handlebars code, {{this.createdAt.toDateString()}}
DB/Post.js
username: String,
createdAt: {
type: Date,
default: new Date()
}
index.js
app.get('/', async (req, res)=>{
const posts = await Post.find().sort({"createdAt": -1})
res.render('index', {
posts
});
})
post.handlebars
{{this.createdAt.toDateString()}}