Reputation:
I'm using SendGrid portal to manage my email templates using handlebar substitutions as its reference in this link https://sendgrid.com/docs/ui/sending-email/using-handlebars/#substitution
I would like to know if it is possible to convert and/or format dates in the SendGrid transactional template portal.
This is my HTML template in SendGrid portal:
<p>This report was generated on {{GenerationTimeUtc}}</p>
This is the dynamic data sent to SendGrid:
{
"GenerationTimeUtc":"2018-09-14T21:16:30.1467851Z"
}
I would like to show it in a more readable way like "This report was generated on May 04" instead of showing "This report was generated on 2018-09-14T21:16:30.1467851Z"
I'm using SendGrid V3
Thanks in advance.
Upvotes: 6
Views: 11160
Reputation: 111
You can make use of formatDate
for this type of formatting, referencing standard dateTime format flags.
<p>Join us {{formatDate dateString "M d"}}</p>
And similar implementation using a different date format…
<p>Join us {{formatDate dateString "yyyy-mm-dd"}}</p>
Upvotes: 9