My MongoDB collection have an ISODate field and I want to format the result to dd/mm/yyyy.
My model:
const Pedido = new Schema({
id: {
type: String,
required: true
},
cliente: {
type: Schema.Types.ObjectId,
ref: 'clientes',
required: true
},
date: {
type:Date
}
})
mongoose.model('pedidos',Pedido)
And that's the query and render:
var query = await Pedido.find().populate('cliente').lean().exec()
res.render("admin/pedidos",{pedidos: query})
I'm using handlebars
{{#each pedidos}}
<h5 class="ordem1">Pedido #{{id}} <small>{{date}}</small></h5>
{{/each}}
It's showing a result like that:
Wed Apr 08 2020 21:00:00 GMT-0300 (GMT-03:00)
but I want to show: 08/04/2020
Could anybody help me with this? Thank you!!