How to format dates with Liquid Script

Rachael Norris
Rachael Norris
  • Updated

Liquid Script is used to dynamically populate information from your Spektrix system into Customer Service Emails sent through Dotdigital.

In this article, we’ll explain how to edit the date and time format in the Liquid Script blocks of your email templates.

Before reading this article, you should be familiar with:

 

What is Liquid Script?

Liquid Script is a markup language which can be used to add personalisation to certain Dotdigital emails using data from your Spektrix system. 

In Spektrix, Liquid Script blocks can be found in the templates of your  Customer Service Emails.

In the templates for Customer Service Emails, you’ll see Liquid Script blocks which look like this:

{{ startDateTime | date: "%A, %d %B %Y" }}

Generally, you won’t be able to edit Liquid Script blocks in your email templates.  We have locked the liquid Script blocks in the templates we provide to protect the functionality of your emails. 

However, you can edit Liquid Script blocks which contain dates and times. These blocks are editable so that you can choose the way dates are displayed to suit your organisation’s preferences.

WARNING: Do not delete Liquid Script blocks from your templates, as this can stop your emails from functioning properly.

 

How to edit the Liquid Script

To edit your date format, follow these steps and use the table in the next section of this article:

  1. Identify the editable Liquid Script block which contains the date and time:

    {{ startDateTime | date: "%A, %d %B %Y" }}

  2. Click into the block to edit the text
     
  3. Add the code in between the quotation marks (“”) after date:
     

    For example, to have your date display as: 

    24 March 2025 19:30

    Amend the code to:

    {{ startDateTime | date: "%d %B %Y %H:%M" }}

  4. Save your changes


 

Date format language

Use the table below to customise the date and time format to your organisation’s preferences.

TIP: Date codes in Liquid Script are case sensitive.

Day name    
Format Output Code
Full name Thursday %A
Shortened name Thu %a


 

Day date    
Format Output Code
Number with leading 0 09 %d
Number without leading 0 9 %e

 

Month    
Format Output Code
Full name March %B
Shortened name Mar %b
Number with leading 0 03 %m
Number without leading 0 3 %-m

 

Year    
Format Output Code
Full year 2024 %Y
Shortened year 24 %y

 

Time    
Format Output Code
24 Hour (00-23) 14 %H
Hour (01-12) 02 %I
AM/PM PM %p
Minute 05 %M


 

Example

To format your date so that it displays as: Thu, 7 March 25 at 7:30PM

You will need to use:

  • %a for Thu
  • &e for 7
  • %B for March
  • %y for 25
  • To add the word at, enter the word outside of the Liquid argument
  • %I for 7
  • :%M for :30
  • %p for PM

In the Liquid Script block this would look like:

{{ startDateTime | date: "%a, %e %B %y" }} at {{ startDateTime | date: "%I:%M%p" }} 

TIP: You can add extra words and punctuation in or around your argument. For example, adding the word at in between your date and time.