Working with Dates in the Subscription Manager

Use the date filter and dayjs to format and compute dates in your Subscription Manager templates
View as Markdown

The Subscription Manager exposes several helper functions that make it easy to display and calculate dates.

Formatting Dates

In Liquid files, you can use the date filter to format a date string (e.g. "2025-02-16") for display:

1<h1>Subscription Start Date: {{ subscription.start_date | date }}</h1>

This will display “Subscription Start Date: February 16, 2025”.

To specify how the date is formatted, pass a format string. The date filter uses dayjs to parse and format dates — refer to their documentation for available formats. For example:

1<p> {{ subscription.start_date | date('YYYY-MM-DD') }} - will display 2025-02-16</p>
2<p> {{ subscription.start_date | date('MMM D, YYYY') }} - will display Feb 16, 2025</p>

Computing Dates

You can also use the dayjs library in the Subscription Manager to manipulate date values, without having to perform date computations yourself.

For example, to calculate a date 15 days after the subscription start date, add this function to your script.js:

1function get15DaysAfterSubscriptionStart(subscription) {
2 return typeof dayjs === 'function' ? dayjs(subscription.start_date).add(15, 'day') : null;
3}

Then display it in a Liquid file:

1{% set expiry_date = 'get15DaysAfterSubscriptionStart(subscription)' | js %}
2<p>{{ expiry_date | date }}</p>

Refer to the dayjs docs for the available manipulation methods.