Я хочу отобразить дату в формате «ГГГГ ММ ДД».
Я пытался использовать код экспресс-руля, {{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()}}