Date, datetime, time, timezone, and time-diff objects.
Time-related object types used when working with dates, times, timezones, and durations in Liquid.
{{ date }}, {{ datetime }}, {{ time }}, {{ timezone }}, and {{ time_diff }} are documented on this page. Format, shift, and convert them with Date Filters. Form markup for date inputs is under Form Fields. {% set_timezone %} lives with Page Metadata.
The value formatted using the "Short date pattern" (MM/dd/yyyy). May include additional markup in the editor preview to make it easier to edit content
Field used to store a date. All dates are stored in UTC time.
ExampleAccess date parts and format time (e.g. am/pm)Access date parts (year, day_of_year, month, day, day_of_week, hour, minute) and format time with am/pm.
Liquid
{%- var meridian = 'am' -%}
{%- var hours = article.post_date.date.hour -%}
{%- if hours > 12 -%}
{%- set hours = hours | minus: 12 -%}
{%- set meridian = 'pm' -%}
{%- endif -%}
The year was {{ article.post_date.date.year }}. It had been {{article.post_date.date.day_of_year}} days, or {{ article.post_date.date.month }} months and {{ article.post_date.date.day }} days past the new year. The day was a {{ article.post_date.date.day_of_week }} and the time was {{ hours }}:{{ article.post_date.date.minute }}{{ meridian }}, but that didn't matter.
ExampleConvert or display dates in a timezone (to_timezone filter)Demonstrates multiple ways to use the to_timezone filter.
Display the article post date in multiple timezones
Liquid
{{ article.post_date | to_timezone: session.user_timezone }} local time
{{- article.post_date | to_timezone: 'UTC' }} UTC
{{- article.post_date | to_timezone: 'Europe/Rome' }} CET
Output
2026-02-16 6:00:00 local time
2026-02-16 10:00:00 UTC
2026-02-16 11:00:00 CET
Convert a date to a different timezone and display it with formatting
ExampleUse a post_date or date-time field with the date filterUse a post_date or other date-time field and format or compare it with the date filter and date properties.
Liquid
{%- if entity.rehearsal_start.is_valid -%}
<p>Rehearsal will begin on {{ entity.rehearsal_start | date: "MMMM dd, yyyy 'at' h:m t" }} UTC</p>
{%- endif -%}
{{ time }}
Represents a specific instant in a specific timezone.
Will be true if the time is in the future and false if the time is in the past. Prevents the page from being fast-cached past when this would change from true to false
The shortened timezone identifier, if applicable, for the given timezone at this instant (may vary depending on time of year, and for some timezones may be the same as the full timezone identifier)
The instant output using the ISO 8601 standard (yyyy-MM-ddTHH:mm:ss.fffffff)
ExampleAccess date parts and format time (e.g. am/pm)Access date parts (year, day_of_year, month, day, day_of_week, hour, minute) and format time with am/pm.
Liquid
{%- var meridian = 'am' -%}
{%- var hours = article.post_date.date.hour -%}
{%- if hours > 12 -%}
{%- set hours = hours | minus: 12 -%}
{%- set meridian = 'pm' -%}
{%- endif -%}
The year was {{ article.post_date.date.year }}. It had been {{article.post_date.date.day_of_year}} days, or {{ article.post_date.date.month }} months and {{ article.post_date.date.day }} days past the new year. The day was a {{ article.post_date.date.day_of_week }} and the time was {{ hours }}:{{ article.post_date.date.minute }}{{ meridian }}, but that didn't matter.
ExampleSet the request timezoneSet the request timezone from a string (e.g. IANA zone) so date/time output uses that zone.
ExampleHow to use the format filter to format datesFormat dates using standard or custom .NET date formats.
Liquid
{% var sep9 = '2009-09-09 14:00:00Z' | date | to_timezone: 'America/New_York' %}
Format a date as a short date string
Liquid
{{sep9 | format: "d"}}
Output
9/9/2009
Formats a date as a short date string (d = short date).
Format a date as a short date string with the time
Liquid
{{sep9 | format: "g"}}
Output
9/9/2009 10:00 AM
Formats a date as a short date string with the time (g = short date with time).
Format a date as a long date string
Liquid
{{sep9 | format: "D"}}
Output
Sunday, September 9, 2009
Formats a date as a long date string (D = long date).
Format a date as a long date string with the time
Liquid
{{sep9 | format: "f"}}
Output
Sunday, September 9, 2009 10:00 AM
Formats a date as a long date string with the time (f = long date with time).
Format a date according to the ISO 8601 standard
Liquid
{{sep9 | format: "o"}}
Output
9/9/2009 2:00:00 PM
Formats a date according to the ISO 8601 standard (o = round trip format with offset).
Format a date as a sortable date string
Liquid
{{sep9 | format: "u"}}
Output
9/9/2009 2:00:00 PM
Formats a date as a sortable date string (u = universal sortable date in UTC timezone).
Format a date to a long date string using a custom date format string
Liquid
{{sep9 | format: "MMMM dd, yyyy 'at' HH:mm:ss"}}
Output
September 09, 2009 at 10:00:00
Formats a date using a custom .NET date format string.
Format a date to a short date string using a custom date format string
Liquid
{{sep9 | format: "hh:mm tt 'on' MM-dd-yy"}}
Output
10:00 AM on 09-09-09
Formats a date using a custom .NET date format string.
You can also use the date filter to format a date
Liquid
{{sep9 | date: "hh:mm tt 'on' MM-dd-yy"}}
Output
10:00 AM on 09-09-09
The date and format filters use the same format strings for dates, but the date filter can only be used to format dates while the format filter can also be used to format numbers and time diffs.
ExampleUse math to manipulate datesUse the add_seconds, add_minutes, add_hours, add_days, add_weeks, add_months, and add_years filters to manipulate dates.
Liquid
{% var startdate = '2009-09-09T00:00:00Z' | to_timezone: 'UTC' %}
add_seconds
Liquid
{{ startdate | add_seconds: 3 }}
Output
9/9/2009 12:00:03 AM
Liquid
{{ startdate | add_seconds: -10239 }}
Output
9/8/2009 9:09:21 PM
add_minutes
Liquid
{{ startdate | add_minutes: 3 }}
Output
9/9/2009 12:03:00 AM
Liquid
{{ startdate | add_minutes: -180 }}
Output
9/8/2009 9:00:00 PM
add_hours
Liquid
{{ startdate | add_hours: 3 }}
Output
9/9/2009 3:00:00 AM
Liquid
{{ startdate | add_hours: -32 }}
Output
9/7/2009 4:00:00 PM
add_days
Liquid
{{ startdate | add_days: 3 }}
Output
9/12/2009 12:00:00 AM
Liquid
{{ startdate | add_days: -2 }}
Output
9/7/2009 12:00:00 AM
add_weeks
Liquid
{{ startdate | add_weeks: 3 }}
Output
9/30/2009 12:00:00 AM
Liquid
{{ startdate | add_weeks: -7 }}
Output
7/22/2009 12:00:00 AM
add_months
Liquid
{{ startdate | add_months: 3 }}
Output
12/9/2009 12:00:00 AM
Liquid
{{ startdate | add_months: -10 }}
Output
11/9/2008 12:00:00 AM
add_years
Liquid
{{ startdate | add_years: 3 }}
Output
9/9/2012 12:00:00 AM
Liquid
{{ startdate | add_years: -1 }}
Output
9/9/2008 12:00:00 AM
ExampleGet Calendar Entries for the Next MonthSet a date range with midnight and add_months, then fetch the next 30 calendar_entries sorted by start_date.
Liquid
{%- var minDate = "now" | midnight -%}
{%- var maxDate = "now" | midnight | add_months: 1 -%}
{%- calendar_entries var entries = start_date:minDate end_date:maxDate limit:30 sort_by:"start_date" sort_direction:"asc" -%}
The minutes component of the difference between the two dates (eg: if the dates are 90 minutes apart this will be 30 since they are 1 hour and 30 minutes apart)
The seconds component of the difference between the two dates (eg: if the dates are 70 seconds apart this will be 10 since they are 1 minute and 10 seconds apart)
The total difference between the two dates expressed as whole and fractional seconds (eg: 122 seconds and 10 milliseconds apart would be 122.1 seconds)
The time diff represented as a string using the standard "constant" format ([-][d.]hh:mm:ss[.fffffff] where all portions of the format in brackets are only included when needed)
ExampleCompute and display a time difference between two datesCompute and display a time difference between two dates.
Liquid
{%- var diff = request.date | time_diff: calendarEntry.start_date -%}
{%- var is_future = true -%}
{%- if diff.total_seconds < 0 -%}
{%- set is_future = false -%}
{%- endif -%}
This event {% if is_future %}will start in{% else %}started{% endif -%}
{%- if diff.days > 0 %}{{diff.days }} days{% endif -%}
{%- if diff.hours > 0 %}{{diff.hours }} hours{% endif -%}
{%- if diff.minutes > 0 %}{{diff.minutes }} minutes{% endif -%}
{%- if diff.hours == 0 and diff.seconds > 0 %}{{diff.seconds }} seconds{% endif -%}
{%- unless is_future %}ago{% endunless -%}
ExampleHow to use the format filter to format time diffsFormat time diffs using standard or custom .NET TimeSpan formats.
Liquid
{% var startdate = '2009-09-09 14:00:00Z' | date | to_timezone: 'America/New_York' %}
{% var enddate = '2009-09-10 17:32:00Z' | date | to_timezone: 'America/New_York' %}
{% var diff = startdate | time_diff: enddate %}
Format a time diff as a constant time span string
Liquid
{{ diff | format: "c" }}
Output
-1.03:32:00
Formats a time diff as a constant time span string (c = constant time span).
Format a time diff as a compact time span string
Liquid
{{ diff | format: "g" }}
Output
-1:3:32:00
Format a time diff using a custom .NET TimeSpan format string
Liquid
{% if diff.total_seconds < 0 %}-{% endif %}{{ diff | format: "d' days, 'h' hours, and 'm' minutes'" }}
Output
-1 days, 3 hours, and 32 minutes
Formats a time diff using a custom .NET TimeSpan format string. Since custom .NET TimeSpan format strings do not have a way to output the minus sign for negative time spans, you have to check for negative time spans separately.