Docs

Log in to read the version of docs relevant to your site, or use the dropdown versions

Mail Merge Fields for Formatting Timestamp

Chargebee follows UTC and the dates are by default displayed in DD-MMM-YYYY format.

Example

An email template that has “Your trial period ends on {{subscription.trial_end}} will be displayed as “Your trial period ends on 23-Jan-2010” to your customers. The time here is in UTC and it is the standard format Chargebee uses to display date fields.

However, Chargebee provides you with the option to format the date and timezone in the desired email template using two mail merge attributes:

  • format: You can use this mail merge attribute to reformat the date and time.
  • timezone: You can use this mail merge attribute to convert the date and time to a specific timezone.

Note

The format and timezone mail merge attributes can only be used with date/timestamp fields.

Follow the steps below to navigate to the email templates and mail-merge fields:

  1. Go to Settings > Configure Chargebee > Email Notifications
  2. Click on the desired email template category.
  3. Click Edit for the desired email template.
  4. Click View all mail merge fields
  5. Select the relevant email notification category from the drop-down menu on top.
  6. Expand the relevant section and find the desired date/timestamp field.

You can now customize these mail merge fields according to the following scenarios and use them while editing your email templates.

Here are a few scenarios with examples:

  1. To display date in a different format and also display the timezone Chargebee uses:

If you want to display “Your trial period ends on 14 May 2016 11:07:00 UTC”, use

{{subscription.trial_end | **format : dd MMM yyyy hh:mm:ss z**}}

  1. To convert and display just the date and time in PST:

If you want to display “Your trial period ends on 14-May-2016 03:07:00”, use

{{subscription.trial_end | **timezone: PST**}}

  1. To display date, time, timezone and convert the timezone to PST, here’s what you can do:

If you want to display “Your trial period ends on 14-May-2016 03:07:00 PST”, use

{{subscription.trial_end | **format : dd-MMM-yyy hh:mm:ss z | timezone: PST**}}

As you can see, when you specify the timezone (PST for example), the date and time are converted from UTC to PST and displayed in the email.

Supported date/time formats

Here's a list of date/time formats that you can use along with the format attribute:

Date and Time PatternResult
"yyyy-MM-dd G 'at' HH:mm:ss z"2001-07-04 AD at 12:08:56 UTC
"EEE, MMM d, ''yy"Wed, Jul 4, '01
"h:mm a"12:08 PM
"hh 'o''clock' a, zzzz"12 o'clock PM, Coordinated Universal Time
"K:mm a, z"0:08 PM, UTC
"yyyyy-MMMM-dd GGG hh:mm aaa"02001-July-04 AD 12:08 PM
"EEE, d MMM yyyy HH:mm:ss Z"Wed, 4 Jul 2001 12:08:56 -0700
"yyMMddHHmmssZ"010704120856-0700
"yyyy-MM-dd'T'HH:mm:ss.SSSZ"2001-07-04T12:08:56.235-0700
"yyyy-MM-dd'T'HH:mm:ss.SSSXXX"2001-07-04T12:08:56.235-07:00
"YYYY-'W'ww-u"2001-W27-3

Note

This is not an exhaustive list of formats supported in Chargebee. You can experiment to find a format that works for you.

Patterns and letters that can be used in formatting

LetterDate or Time ComponentPresentationExamples
GEra designatorTextAD
yYearYear1996; 96
YWeek yearYear2009; 09
MMonth in yearMonthJuly; Jul; 07
wWeek in yearNumber27
WWeek in monthNumber2
DDay in yearNumber189
dDay in monthNumber10
FDay of week in monthNumber2
EDay name in weekTextTuesday; Tue
uDay number of week (1 = Monday, ..., 7 = Sunday)Number1
aam/pm markerTextPM
HHour in day (0-23)Number0
kHour in day (1-24)Number24
KHour in am/pm (0-11)Number0
hHour in am/pm (1-12)Number12
mMinute in hourNumber30
sSecond in minuteNumber55
SMillisecondNumber978
zTime zoneGeneral time zoneCoordinated Universal Time; UTC
ZTime zoneRFC 822 time zone+0000
XTime zoneISO 8601 time zone+00; +0000; +00:00

Note

  • Formatting using dots is not supported. For example, "yyyy.MM.dd G 'at' HH:mm:ss z" is not supported, but you can format it as "yyyy-MM-dd G 'at' HH:mm:ss z" since dashes (-) are supported.
  • If you preview your email template, since the preview values are static, you will not be able to see the actual effect of the format and timezone attributes. You should save your template and test by generating an email.
  • We strongly recommend that you try template changes in your test site first before applying them to your live site.

Was this article helpful?