Date / Time Formatting in Merge Fields and Exports

Slate allows for the formatting of standard date and time values for use in exports and merges. 

Formatting Date / Time Merge Fields

When merging in/exporting date/time information such as "Form-Date" for an event mailing, it's possible to control both:

  • Which date and time information to show, and
  • How the date and time information is shown
For Mailings and Confirmation Pages

The date filter in Liquid markup allows modifications to how Slate displays date/times. There are several merge fields that automatically include the date filter and a predefined format, such as: "Form-Date-Time", "Form-Date", and "Form-Time".

Below are some examples of how the date filter works in Liquid markup:

Input Merge Field Result
"12/01/2017 08:01 PM"  {{Form-Date | date: 'MMMM d, yyyy'}} December 1, 2017
"1/31/2018 09:30 AM"  {{Form-Date | date: 'h:mm tt'}} 9:30 AM
"2/15/2018 07:00 AM" {{Form-Date | date: 'dddd, MMMM d'}} at {{Form-Date | date: 'h:mm tt'}} Thursday, February 15 at 7:00 AM
For Exports in Queries

Selecting either the "DateTime" or "Date" Format Type for an export allows the designation of a Format Mask. This Format Mask uses the same syntax as Liquid markup.

datetimeformatmask.png

Related Event Dates and Times

Slate will generate merge fields for related event selectors that have an export key, such as "info_session". These merge fields will carry the export key of the corresponding related events selector, and there are two variations:

  • Simple, such as {{info_session}}
  • Advanced, such as {{info_session-data}}. Slate will suffix the merge field with "-data"
Simple Merge Field

The simple merge field, like {{info_session}}, will output the related event's date (in "dddd, MMMM d" format) and title. For instance, an info session occurring on "1/31/2018 09:30 AM" would display as "Wednesday, January 1 - Info Session".

Advanced merge Field

The advanced merge field, such as {{info_session-data}}, will add the following to a mailing/confirmation page:

{% for event in info_session-Data %}
{{event.datetime | date:"dddd, MMMM d \a\t h:mm tt"}} - {{event.summary}}
{% endfor %}

Please note the following merge fields to retain/remove/manipulate:

  • {{event.datetime}}
  • {{event.summary}}
Multiple Related Events

If you want to display all Related Events selected on a form in chronological order, you can use the {{Form-Related-Events}} merge field. This merge field can also be edited in a similar manner discussed in the previous discussion.

Date Formatting
Days
Format Specifier Description Example
d Day of the month (1 to 31) "12/01/2017 08:01 PM" → 1
"1/31/2018 09:30 AM" → 31
dd Day of the month with a leading zero (01 to 31) "12/01/2017 08:01 PM" → 01
"1/31/2018 09:30 AM" → 31
ddd Abbreviated name of the day of the week "12/01/2017 08:01 PM" → Fri
"1/31/2018 09:30 AM" → Wed
dddd Full name of the day of the week "12/01/2017 08:01 PM" → Friday
"1/31/2018 09:30 AM" → Wednesday
Months
Format Specifier Description Example
M Month (1 to 12) "12/01/2017 08:01 PM" → 12
"1/31/2018 09:30 AM" → 1
MM Month with a leading zero (01 to 12) "12/01/2017 08:01 PM" → 12
"1/31/2018 09:30 AM" → 01
MMM Abbreviated name of the month "12/01/2017 08:01 PM" → Dec
"1/31/2018 09:30 AM" → Jan
MMMM Full name of the month "12/01/2017 08:01 PM" → December
"1/31/2018 09:30 AM" → January
Years
Format Specifier Description Example
yyyy Year "12/01/2017 08:01 PM" → 2017
"1/31/2018 09:30 AM" → 2018
Time Formatting
Minutes
Format Specifier Description Example
m The minute (0 to 59) "12/01/2017 08:01 PM" → 1
"1/31/2018 09:30 AM" → 30
mm The minute with a leading zero (00 to 59) "12/01/2017 08:01PM" → 01
"1/31/2018 09:30 AM" → 30
Hours
Format Specifier Description Example
h The hour, using 12-hour time (1 to 12) "12/01/2017 08:01 PM" → 8
"1/31/2018 09:30 AM" → 9
hh The hour, using 12-hour time, with a leading zero (01 to 12) "12/01/2017 08:01PM" → 08
"1/31/2018 09:30 AM" → 09
H The hour, using 24-hour time (0 to 23) "12/01/2017 08:01PM" → 20
"1/31/2018 09:30 AM" → 9
HH The hour, using 24-hour time, with a leading zero (0 to 23) "12/01/2017 08:01PM" → 20
"1/31/2018 09:30 AM" → 09
AM / PM Designation
Format Specifier Description Example
tt The AM/PM designator "12/01/2017 08:01 PM" → PM
"1/31/2018 09:30 AM" → AM
Was this article helpful?
16 out of 17 found this helpful

Comments

0 comments

Please sign in to leave a comment.