Docs
Chargebee follows UTC and the dates are by default displayed in DD-MMM-YYYY format.
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:
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:
Go to Settings > Configure Chargebee > Email Notifications
Click on the desired email template category.
Click Edit for the desired email template.
Click View all mail merge fields
Select the relevant email notification category from the drop-down menu on top.
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.
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}}
If you want to display "Your trial period ends on 14-May-2016 03:07:00", use
{{subscription.trial_end | timezone: PST}}
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.
Here's a list of date/time formats that you can use along with the format attribute:
Date and Time Pattern |
Result |
"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 |
This is not an exhaustive list of formats supported in Chargebee. You can experiment to find a format that works for you.
Letter |
Date or Time Component |
Presentation |
Examples |
G |
Era designator |
AD |
|
y |
Year |
1996; 96 |
|
Y |
Week year |
2009; 09 |
|
M |
Month in year |
July; Jul; 07 |
|
w |
Week in year |
27 |
|
W |
Week in month |
2 |
|
D |
Day in year |
189 |
|
d |
Day in month |
10 |
|
F |
Day of week in month |
2 |
|
E |
Day name in week |
Tuesday; Tue |
|
u |
Day number of week (1 = Monday, ..., 7 = Sunday) |
1 |
|
a |
am/pm marker |
PM |
|
H |
Hour in day (0-23) |
0 |
|
k |
Hour in day (1-24) |
24 |
|
K |
Hour in am/pm (0-11) |
0 |
|
h |
Hour in am/pm (1-12) |
12 |
|
m |
Minute in hour |
30 |
|
s |
Second in minute |
55 |
|
S |
Millisecond |
978 |
|
z |
Time zone |
Coordinated Universal Time; UTC |
|
Z |
Time zone |
+0000 |
|
X |
Time zone |
+00; +0000; +00:00 |
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.