Datetime

Datetime

{{ datetime }}

A field containing a user-selected date

Properties of {{ datetime }} objects
Name Type Description
is_valid Boolean True if the value is not empty
value String Unformatted date string (in UTC)
date time An object containing more detailed information about the selected date and time
default_value String The default value for this field if no value is specified
field_id String The identifier for this field
label String The label for this field
output String 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.

Related

object

May be any object, including simple, complex and list objects. In some cases may even include symbols and null.

{{ form }}

{{ calendar_entry }}

{{ select }}

{{ date }}

A field containing a user-selected date

{{ blog_post }}

string

Can be any text, from the empty string ("") to the full HTML output of the template. When used alone in a conditional, all strings evaluates as true - even if they are empty or a value such as "0" or "false".

{{ article }}

{{ time }}

Represents a specific instant in a specific timezone.

Examples

Use the add_seconds, add_minutes, add_hours, add_days, add_weeks, add_months, and add_years filters to manipulate dates.

Use math to manipulate dates

Copy
{% var startdate = '2009-09-09T00:00:00Z' | to_timezone: 'UTC' %}

add_seconds

{{ startdate | add_seconds: 3 }}
9/9/2009 12:00:03 AM
{{ startdate | add_seconds: -10239 }}
9/8/2009 9:09:21 PM

add_minutes

{{ startdate | add_minutes: 3 }}
9/9/2009 12:03:00 AM
{{ startdate | add_minutes: -180 }}
9/8/2009 9:00:00 PM

add_hours

{{ startdate | add_hours: 3 }}
9/9/2009 3:00:00 AM
{{ startdate | add_hours: -32 }}
9/7/2009 4:00:00 PM

add_days

{{ startdate | add_days: 3 }}
9/12/2009 12:00:00 AM
{{ startdate | add_days: -2 }}
9/7/2009 12:00:00 AM

add_weeks

{{ startdate | add_weeks: 3 }}
9/30/2009 12:00:00 AM
{{ startdate | add_weeks: -7 }}
7/22/2009 12:00:00 AM

add_months

{{ startdate | add_months: 3 }}
12/9/2009 12:00:00 AM
{{ startdate | add_months: -10 }}
11/9/2008 12:00:00 AM

add_years

{{ startdate | add_years: 3 }}
9/9/2012 12:00:00 AM
{{ startdate | add_years: -1 }}
9/9/2008 12:00:00 AM

You can use the date filter either to create a date object or to format a date as a string.

Many ways to use the date filter

Copy
{% set_timezone 'UTC' %}

create a date object

{{ "2009-09-09" | date }}
9/9/2009 12:00:00 AM
{{ "2009-09-09" | date: "D" }}
Wednesday, September 9, 2009
{{ 0 | date: "D" }}
Thursday, January 1, 1970
{{ 1756239994 | date: "D" }}
Tuesday, August 26, 2025

Defaults to the current date

{{"now" | date}}
2009-09-09T00:00:00.0000000+00:00 (or whatever the current date is)

format a date as a string

{{request.date | date: "d"}}
9/9/2009
{{request.date | date: "D"}}
Sunday, September 9, 2009
{{request.date | date: "o"}}
9/9/2009 12:00:00 AM
{{request.date | date: "MMMM dd, yyyy"}}
September 09, 2009

Demonstrates how to entity Date Opened with Date Filter.

Entity Date Opened with Date Filter

Copy
{% if entity.date_opened.is_valid %}
<p><strong>Date Opened</strong>: {{ entity.date_opened | date: "MMMM dd, yyyy" }}</p>
{% endif %}

Demonstrates how to assign date add month and fetch calendar_entries.

Assign date add month and fetch calendar_entries

Copy
{% assign minDate = "now" | midnight %}
{% assign maxDate = minDate | add_months: 1 %}
{% calendar_entries output_to_template start_date:minDate end_date:maxDate limit:30 sort_by:"start_date" sort_direction:"asc" %}

Demonstrates how to var date assignment and date math.

Var date assignment and date math

Copy
{% var minDate = "now" | midnight %}
{% var maxDate = "now" | midnight | add_months: 1 %}
{% calendar_entry_collection output_to_template start_date:minDate end_date:maxDate limit:30 sort_by:"start_date" sort_direction:"asc" %}

Format dates using standard or custom .NET date formats.

Format Dates

Copy
{{request.date | format: "d"}}
9/9/2009
{{request.date | format: "D"}}
Sunday, September 9, 2009
{{request.date | format: "o"}}
9/9/2009 12:00:00 AM
{{request.date | format: "MMMM dd, yyyy"}}
September 09, 2009

Demonstrates how to time advanced.

Time advanced

Copy
{% 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.

Demonstrates multiple ways to use the to_timezone filter.

Using the to_timezone filter

Copy

Display the article post date in multiple timezones

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

{% if entity.alt_timezone.is_valid %}
{{ entity.alt_date | to_timezone: entity.alt_timezone | date: 'f' }} {{ entity.alt_timezone }}
{% endif %}
2026-02-16 12:00:00

date filter

Returns the input as a date. If format is specified, converts the date to a string before returning it using the given format. The format must be a valid standard or custom .NET date format.

date: String format

If the input is already a date object, it will be used as-is - either to be formatted or returned without alteration. If the input is a number, it will be interpreted as a unix timestamp - that is the seconds since the Unix Epoch (midnight on January 1, 1970 UTC). If the input is not already a date and is not a number, it will attempt to parse it as the string representation of a date. If the input cannot be converted to a date using any of the previous methods, it will use the current date and time - which will prevent the page from being fast-cached. In all cases where the date filter creates a new date object, it uses the current timezone - which defaults to the site&#39;s timezone but may be set explicitly using the {% set_timezone %} method.

Examples

You can use the date filter either to create a date object or to format a date as a string.

Many ways to use the date filter

Copy
{% set_timezone 'UTC' %}

create a date object

{{ "2009-09-09" | date }}
9/9/2009 12:00:00 AM
{{ "2009-09-09" | date: "D" }}
Wednesday, September 9, 2009
{{ 0 | date: "D" }}
Thursday, January 1, 1970
{{ 1756239994 | date: "D" }}
Tuesday, August 26, 2025

Defaults to the current date

{{"now" | date}}
2009-09-09T00:00:00.0000000+00:00 (or whatever the current date is)

format a date as a string

{{request.date | date: "d"}}
9/9/2009
{{request.date | date: "D"}}
Sunday, September 9, 2009
{{request.date | date: "o"}}
9/9/2009 12:00:00 AM
{{request.date | date: "MMMM dd, yyyy"}}
September 09, 2009

Related

{{ date }}

A field containing a user-selected date

{{ date_field }}

Should be used to display a date field inside a form.

time_diff filter

If format is unspecified, returns a time_diff object describing the difference between the current date and the other date. If format is specified, converts the time difference to a string before returning it using the given format. If supplied, the format must be a valid standard or custom .NET TimeSpan format.

time_diff: time otherString format

Examples

Format time diffs using standard or custom .NET TimeSpan formats.

Format Time Diffs

Copy
{% var diff = request.date | add_days: 3 | time_diff: request.date %}
{{ diff | format: "g" }}
-3:0:00:00
{{ diff | format: "dd 'days'" }}
03 days

Demonstrates how to time diff.

Time diff

Copy
{% 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 %}

Related

{{ time_diff }}

Contains information about the difference between two dates.

{{ time }}

Represents a specific instant in a specific timezone.

timezone filter

Returns the timezone that the date is in. If full is true or if an abbreviated timezone name is not available, returns the full timezone identifier (eg: &quot;Europe/Rome&quot;). If full is false (default) or not specified and an abbreviated timezone name is available returns the abbreviated timezone name (eg: &quot;PST&quot; or &quot;PDT&quot;).

timezone: Boolean full

Examples

Use the timezone filter to output the timezone used by a date object. The output may either be the full timezone identifier or the shortened timezone abbreviation.

Using the timezone filter

Copy
{{request.date | timezone}}
EST
{{request.date | add_months: 6 | timezone}}
EDT
{{request.date | timezone: true}}
America/Indiana/Indianapolis

Related

{{ timezone }}

to_timezone filter

Converts a date to the specified timezone.

to_timezone: String timezone

Related

{{ timezone }}

{% set_timezone %}

Sets the default timezone to use when rendering dates and times on the page that do not already have a separate timezone configured.

add_minutes filter

Return a date object operand minutes in the future from the input date.

add_minutes: Integer operand

If operand is negative, return a date that many minutes in the past from the input date.

Examples

Use the add_seconds, add_minutes, add_hours, add_days, add_weeks, add_months, and add_years filters to manipulate dates.

Use math to manipulate dates

Copy
{% var startdate = '2009-09-09T00:00:00Z' | to_timezone: 'UTC' %}

add_seconds

{{ startdate | add_seconds: 3 }}
9/9/2009 12:00:03 AM
{{ startdate | add_seconds: -10239 }}
9/8/2009 9:09:21 PM

add_minutes

{{ startdate | add_minutes: 3 }}
9/9/2009 12:03:00 AM
{{ startdate | add_minutes: -180 }}
9/8/2009 9:00:00 PM

add_hours

{{ startdate | add_hours: 3 }}
9/9/2009 3:00:00 AM
{{ startdate | add_hours: -32 }}
9/7/2009 4:00:00 PM

add_days

{{ startdate | add_days: 3 }}
9/12/2009 12:00:00 AM
{{ startdate | add_days: -2 }}
9/7/2009 12:00:00 AM

add_weeks

{{ startdate | add_weeks: 3 }}
9/30/2009 12:00:00 AM
{{ startdate | add_weeks: -7 }}
7/22/2009 12:00:00 AM

add_months

{{ startdate | add_months: 3 }}
12/9/2009 12:00:00 AM
{{ startdate | add_months: -10 }}
11/9/2008 12:00:00 AM

add_years

{{ startdate | add_years: 3 }}
9/9/2012 12:00:00 AM
{{ startdate | add_years: -1 }}
9/9/2008 12:00:00 AM

Related

{% add_stylesheet %}

Add a stylesheet asset to the head of the current page via a <link> tag

{% add_javascript %}

Add a script asset to the current page via a <script> tag

{% add_javascript inline %}

Outputs javascript code in an inline script

{% add_stylesheet inline %}

Outputs an inline stylesheet in a <style> tag.

add_years filter

Return a date object operand years in the future from the input date.

add_years: Integer operand

If operand is negative, return a date that many years in the past from the input date.

Examples

Use the add_seconds, add_minutes, add_hours, add_days, add_weeks, add_months, and add_years filters to manipulate dates.

Use math to manipulate dates

Copy
{% var startdate = '2009-09-09T00:00:00Z' | to_timezone: 'UTC' %}

add_seconds

{{ startdate | add_seconds: 3 }}
9/9/2009 12:00:03 AM
{{ startdate | add_seconds: -10239 }}
9/8/2009 9:09:21 PM

add_minutes

{{ startdate | add_minutes: 3 }}
9/9/2009 12:03:00 AM
{{ startdate | add_minutes: -180 }}
9/8/2009 9:00:00 PM

add_hours

{{ startdate | add_hours: 3 }}
9/9/2009 3:00:00 AM
{{ startdate | add_hours: -32 }}
9/7/2009 4:00:00 PM

add_days

{{ startdate | add_days: 3 }}
9/12/2009 12:00:00 AM
{{ startdate | add_days: -2 }}
9/7/2009 12:00:00 AM

add_weeks

{{ startdate | add_weeks: 3 }}
9/30/2009 12:00:00 AM
{{ startdate | add_weeks: -7 }}
7/22/2009 12:00:00 AM

add_months

{{ startdate | add_months: 3 }}
12/9/2009 12:00:00 AM
{{ startdate | add_months: -10 }}
11/9/2008 12:00:00 AM

add_years

{{ startdate | add_years: 3 }}
9/9/2012 12:00:00 AM
{{ startdate | add_years: -1 }}
9/9/2008 12:00:00 AM

Related

{% add_stylesheet %}

Add a stylesheet asset to the head of the current page via a <link> tag

{% add_javascript %}

Add a script asset to the current page via a <script> tag

{% add_javascript inline %}

Outputs javascript code in an inline script

{% add_stylesheet inline %}

Outputs an inline stylesheet in a <style> tag.

add_months filter

Return a date object operand months in the future from the input date.

add_months: Integer operand

If operand is negative, return a date that many months in the past from the input date.

Examples

Use the add_seconds, add_minutes, add_hours, add_days, add_weeks, add_months, and add_years filters to manipulate dates.

Use math to manipulate dates

Copy
{% var startdate = '2009-09-09T00:00:00Z' | to_timezone: 'UTC' %}

add_seconds

{{ startdate | add_seconds: 3 }}
9/9/2009 12:00:03 AM
{{ startdate | add_seconds: -10239 }}
9/8/2009 9:09:21 PM

add_minutes

{{ startdate | add_minutes: 3 }}
9/9/2009 12:03:00 AM
{{ startdate | add_minutes: -180 }}
9/8/2009 9:00:00 PM

add_hours

{{ startdate | add_hours: 3 }}
9/9/2009 3:00:00 AM
{{ startdate | add_hours: -32 }}
9/7/2009 4:00:00 PM

add_days

{{ startdate | add_days: 3 }}
9/12/2009 12:00:00 AM
{{ startdate | add_days: -2 }}
9/7/2009 12:00:00 AM

add_weeks

{{ startdate | add_weeks: 3 }}
9/30/2009 12:00:00 AM
{{ startdate | add_weeks: -7 }}
7/22/2009 12:00:00 AM

add_months

{{ startdate | add_months: 3 }}
12/9/2009 12:00:00 AM
{{ startdate | add_months: -10 }}
11/9/2008 12:00:00 AM

add_years

{{ startdate | add_years: 3 }}
9/9/2012 12:00:00 AM
{{ startdate | add_years: -1 }}
9/9/2008 12:00:00 AM

Related

{% add_stylesheet %}

Add a stylesheet asset to the head of the current page via a <link> tag

{% add_javascript %}

Add a script asset to the current page via a <script> tag

{% add_javascript inline %}

Outputs javascript code in an inline script

{% add_stylesheet inline %}

Outputs an inline stylesheet in a <style> tag.

add_weeks filter

Return a date object operand weeks in the future from the input date.

add_weeks: Integer operand

If operand is negative, return a date that many weeks in the past from the input date.

Examples

Use the add_seconds, add_minutes, add_hours, add_days, add_weeks, add_months, and add_years filters to manipulate dates.

Use math to manipulate dates

Copy
{% var startdate = '2009-09-09T00:00:00Z' | to_timezone: 'UTC' %}

add_seconds

{{ startdate | add_seconds: 3 }}
9/9/2009 12:00:03 AM
{{ startdate | add_seconds: -10239 }}
9/8/2009 9:09:21 PM

add_minutes

{{ startdate | add_minutes: 3 }}
9/9/2009 12:03:00 AM
{{ startdate | add_minutes: -180 }}
9/8/2009 9:00:00 PM

add_hours

{{ startdate | add_hours: 3 }}
9/9/2009 3:00:00 AM
{{ startdate | add_hours: -32 }}
9/7/2009 4:00:00 PM

add_days

{{ startdate | add_days: 3 }}
9/12/2009 12:00:00 AM
{{ startdate | add_days: -2 }}
9/7/2009 12:00:00 AM

add_weeks

{{ startdate | add_weeks: 3 }}
9/30/2009 12:00:00 AM
{{ startdate | add_weeks: -7 }}
7/22/2009 12:00:00 AM

add_months

{{ startdate | add_months: 3 }}
12/9/2009 12:00:00 AM
{{ startdate | add_months: -10 }}
11/9/2008 12:00:00 AM

add_years

{{ startdate | add_years: 3 }}
9/9/2012 12:00:00 AM
{{ startdate | add_years: -1 }}
9/9/2008 12:00:00 AM

Related

{% add_stylesheet %}

Add a stylesheet asset to the head of the current page via a <link> tag

{% add_javascript %}

Add a script asset to the current page via a <script> tag

{% add_javascript inline %}

Outputs javascript code in an inline script

{% add_stylesheet inline %}

Outputs an inline stylesheet in a <style> tag.

add_hours filter

Return a date object operand hours in the future from the input date.

add_hours: Integer operand

If operand is negative, return a date that many hours in the past from the input date.

Examples

Use the add_seconds, add_minutes, add_hours, add_days, add_weeks, add_months, and add_years filters to manipulate dates.

Use math to manipulate dates

Copy
{% var startdate = '2009-09-09T00:00:00Z' | to_timezone: 'UTC' %}

add_seconds

{{ startdate | add_seconds: 3 }}
9/9/2009 12:00:03 AM
{{ startdate | add_seconds: -10239 }}
9/8/2009 9:09:21 PM

add_minutes

{{ startdate | add_minutes: 3 }}
9/9/2009 12:03:00 AM
{{ startdate | add_minutes: -180 }}
9/8/2009 9:00:00 PM

add_hours

{{ startdate | add_hours: 3 }}
9/9/2009 3:00:00 AM
{{ startdate | add_hours: -32 }}
9/7/2009 4:00:00 PM

add_days

{{ startdate | add_days: 3 }}
9/12/2009 12:00:00 AM
{{ startdate | add_days: -2 }}
9/7/2009 12:00:00 AM

add_weeks

{{ startdate | add_weeks: 3 }}
9/30/2009 12:00:00 AM
{{ startdate | add_weeks: -7 }}
7/22/2009 12:00:00 AM

add_months

{{ startdate | add_months: 3 }}
12/9/2009 12:00:00 AM
{{ startdate | add_months: -10 }}
11/9/2008 12:00:00 AM

add_years

{{ startdate | add_years: 3 }}
9/9/2012 12:00:00 AM
{{ startdate | add_years: -1 }}
9/9/2008 12:00:00 AM

Related

{% add_stylesheet %}

Add a stylesheet asset to the head of the current page via a <link> tag

{% add_javascript %}

Add a script asset to the current page via a <script> tag

{% add_javascript inline %}

Outputs javascript code in an inline script

{% add_stylesheet inline %}

Outputs an inline stylesheet in a <style> tag.

add_days filter

Return a date object operand days in the future from the input date.

add_days: Integer operand

If operand is negative, return a date that many days in the past from the input date.

Examples

Use the add_seconds, add_minutes, add_hours, add_days, add_weeks, add_months, and add_years filters to manipulate dates.

Use math to manipulate dates

Copy
{% var startdate = '2009-09-09T00:00:00Z' | to_timezone: 'UTC' %}

add_seconds

{{ startdate | add_seconds: 3 }}
9/9/2009 12:00:03 AM
{{ startdate | add_seconds: -10239 }}
9/8/2009 9:09:21 PM

add_minutes

{{ startdate | add_minutes: 3 }}
9/9/2009 12:03:00 AM
{{ startdate | add_minutes: -180 }}
9/8/2009 9:00:00 PM

add_hours

{{ startdate | add_hours: 3 }}
9/9/2009 3:00:00 AM
{{ startdate | add_hours: -32 }}
9/7/2009 4:00:00 PM

add_days

{{ startdate | add_days: 3 }}
9/12/2009 12:00:00 AM
{{ startdate | add_days: -2 }}
9/7/2009 12:00:00 AM

add_weeks

{{ startdate | add_weeks: 3 }}
9/30/2009 12:00:00 AM
{{ startdate | add_weeks: -7 }}
7/22/2009 12:00:00 AM

add_months

{{ startdate | add_months: 3 }}
12/9/2009 12:00:00 AM
{{ startdate | add_months: -10 }}
11/9/2008 12:00:00 AM

add_years

{{ startdate | add_years: 3 }}
9/9/2012 12:00:00 AM
{{ startdate | add_years: -1 }}
9/9/2008 12:00:00 AM

Related

{% add_stylesheet %}

Add a stylesheet asset to the head of the current page via a <link> tag

{% add_javascript %}

Add a script asset to the current page via a <script> tag

{% add_javascript inline %}

Outputs javascript code in an inline script

{% add_stylesheet inline %}

Outputs an inline stylesheet in a <style> tag.

add_seconds filter

Return a date object operand seconds in the future from the input date.

add_seconds: Integer operand

If operand is negative, return a date that many seconds in the past from the input date.

Examples

Use the add_seconds, add_minutes, add_hours, add_days, add_weeks, add_months, and add_years filters to manipulate dates.

Use math to manipulate dates

Copy
{% var startdate = '2009-09-09T00:00:00Z' | to_timezone: 'UTC' %}

add_seconds

{{ startdate | add_seconds: 3 }}
9/9/2009 12:00:03 AM
{{ startdate | add_seconds: -10239 }}
9/8/2009 9:09:21 PM

add_minutes

{{ startdate | add_minutes: 3 }}
9/9/2009 12:03:00 AM
{{ startdate | add_minutes: -180 }}
9/8/2009 9:00:00 PM

add_hours

{{ startdate | add_hours: 3 }}
9/9/2009 3:00:00 AM
{{ startdate | add_hours: -32 }}
9/7/2009 4:00:00 PM

add_days

{{ startdate | add_days: 3 }}
9/12/2009 12:00:00 AM
{{ startdate | add_days: -2 }}
9/7/2009 12:00:00 AM

add_weeks

{{ startdate | add_weeks: 3 }}
9/30/2009 12:00:00 AM
{{ startdate | add_weeks: -7 }}
7/22/2009 12:00:00 AM

add_months

{{ startdate | add_months: 3 }}
12/9/2009 12:00:00 AM
{{ startdate | add_months: -10 }}
11/9/2008 12:00:00 AM

add_years

{{ startdate | add_years: 3 }}
9/9/2012 12:00:00 AM
{{ startdate | add_years: -1 }}
9/9/2008 12:00:00 AM

Related

{% add_stylesheet %}

Add a stylesheet asset to the head of the current page via a <link> tag

{% add_javascript %}

Add a script asset to the current page via a <script> tag

{% add_javascript inline %}

Outputs javascript code in an inline script

{% add_stylesheet inline %}

Outputs an inline stylesheet in a <style> tag.

Conditions

is_date

Returns true if the subject is a date object. If the operand is true,will check if the object is a string that can be safely converted to true or false (eg: {% if subject is_date true %}).

Related:

{{ date }}

A field containing a user-selected date

{{ date_field }}

Should be used to display a date field inside a form.