Closed Sharcoux closed 4 years ago
This should work.
const moment = require('moment')
const someDate = new Date()
email
.send({
template: 'mars',
message: {
to: 'elon@spacex.com'
},
locals: {
moment: moment,
date: someDate
}
})
.then(console.log)
.catch(console.error);
// html.pug
p Display year of date: #{moment(date).format('YYYY')}
Forgive me if my question sounds stupid, but how can I use momentJS to format dates in an email template?
I wish I could use something like:
b #{moment(date).format('dddd Do MMM YYYY à HH:mm:ss')}
I'd prefer doing this in the email because I think that formating the date and deciding about how to render the information is something that should belong to the template and not the method that would send the email.
What is the way to proceed?