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 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

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 

Letter

Date or Time Component

Presentation

Examples

G

Era designator

Text 

AD

y

Year

Year 

1996; 96

Y

Week year

Year 

2009; 09

M

Month in year

Month 

July; Jul; 07

w

Week in year

Number 

27

W

Week in month

Number 

2

D

Day in year

Number 

189

d

Day in month

Number 

10

F

Day of week in month

Number 

2

E

Day name in week

Text 

Tuesday; Tue

u

Day number of week (1 = Monday, ..., 7 = Sunday)

Number 

1

a

am/pm marker

Text 

PM

H

Hour in day (0-23)

Number 

0

k

Hour in day (1-24)

Number 

24

K

Hour in am/pm (0-11)

Number 

0

h

Hour in am/pm (1-12)

Number 

12

m

Minute in hour

Number 

30

s

Second in minute

Number 

55

S

Millisecond

Number 

978

z

Time zone

General time zone 

Coordinated Universal Time; UTC

Z

Time zone

RFC 822 time zone 

+0000

X

Time zone

ISO 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?
Loading…