Date Filters

Date

{{ date }}

A field containing a user-selected date

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

{{ date_field }}

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

Name Type Description
is_valid Boolean Will always be true
type String Will always be "date"
default_value time Optional. The default value to use for this date field when the form is displayed. Will be null if there is no default value
map_to_attribute String If the user is signed into a profile when they submit this form and map_to_attribute is set, the profile attribute specified in map_to_attribute will be set to the value of this field. This should also be used to override the default value if the user is signed into a profile and the specified attribute has already been set
required Boolean Will be true if the user is required to enter a date before submitting the form
required_message String The message to display when the user attempts to submit the form without entering a date
validators validators The list of validators that should be used to validate this date field, if applicable
element_id String A helper property containing a unique ID for this field on this instance of this form. This value should be different every time the form is output
subtext text Help or hint text to display together with the field
condition condition The condition that should be used to show and hide this form field
classname String CSS class name(s) to be applied to the field
field_id String The identifier for this field
label String The label for this field
output String Default HTML markup for this date field, which makes a number of assumptions about other elements on the page that may or may not be included. Developers should avoid using the default output in order to guarantee that forms work as expected, including styling, validation, conditionals, and more. May include additional markup in the editor preview to make it easier to edit content

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 }}
{{ startdate | add_seconds: -10239 }}

add_minutes

{{ startdate | add_minutes: 3 }}
{{ startdate | add_minutes: -180 }}

add_hours

{{ startdate | add_hours: 3 }}
{{ startdate | add_hours: -32 }}

add_days

{{ startdate | add_days: 3 }}
{{ startdate | add_days: -2 }}

add_weeks

{{ startdate | add_weeks: 3 }}
{{ startdate | add_weeks: -7 }}

add_months

{{ startdate | add_months: 3 }}
{{ startdate | add_months: -10 }}

add_years

{{ startdate | add_years: 3 }}
{{ startdate | add_years: -1 }}

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 }}
{{ "2009-09-09" | date: "D" }}
{{ 0 | date: "D" }}
{{ 1756239994 | date: "D" }}

Defaults to the current date

{{"now" | date}}

format a date as a string

{{request.date | date: "d"}}
{{request.date | date: "D"}}
{{request.date | date: "o"}}
{{request.date | date: "MMMM dd, yyyy"}}

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

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" %}

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"}}
{{request.date | format: "D"}}
{{request.date | format: "o"}}
{{request.date | format: "MMMM dd, yyyy"}}

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.

To timezone filter

Copy
{{ article.post_date | to_timezone: session.user_timezone }}

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

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 }}
{{ "2009-09-09" | date: "D" }}
{{ 0 | date: "D" }}
{{ 1756239994 | date: "D" }}

Defaults to the current date

{{"now" | date}}

format a date as a string

{{request.date | date: "d"}}
{{request.date | date: "D"}}
{{request.date | date: "o"}}
{{request.date | date: "MMMM dd, yyyy"}}

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" }}
{{ diff | format: "dd 'days'" }}

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

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: "Europe/Rome"). If full is false (default) or not specified and an abbreviated timezone name is available returns the abbreviated timezone name (eg: "PST" or "PDT").

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}}
{{request.date | add_months: 6 | timezone}}
{{request.date | timezone: true}}

to_timezone filter

Converts a date to the specified timezone.

to_timezone: String timezone

Examples

Use the to_timezone filter to convert a date to a specific timezone.

Using the to_timezone filter

Copy
{{request.date | to_timezone: 'UTC'}}
{{request.date | to_timezone: 'Europe/Rome'}}

add_minutes filter

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

add_minutes: Integer operand

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 }}
{{ startdate | add_seconds: -10239 }}

add_minutes

{{ startdate | add_minutes: 3 }}
{{ startdate | add_minutes: -180 }}

add_hours

{{ startdate | add_hours: 3 }}
{{ startdate | add_hours: -32 }}

add_days

{{ startdate | add_days: 3 }}
{{ startdate | add_days: -2 }}

add_weeks

{{ startdate | add_weeks: 3 }}
{{ startdate | add_weeks: -7 }}

add_months

{{ startdate | add_months: 3 }}
{{ startdate | add_months: -10 }}

add_years

{{ startdate | add_years: 3 }}
{{ startdate | add_years: -1 }}

add_years filter

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

add_years: Integer operand

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 }}
{{ startdate | add_seconds: -10239 }}

add_minutes

{{ startdate | add_minutes: 3 }}
{{ startdate | add_minutes: -180 }}

add_hours

{{ startdate | add_hours: 3 }}
{{ startdate | add_hours: -32 }}

add_days

{{ startdate | add_days: 3 }}
{{ startdate | add_days: -2 }}

add_weeks

{{ startdate | add_weeks: 3 }}
{{ startdate | add_weeks: -7 }}

add_months

{{ startdate | add_months: 3 }}
{{ startdate | add_months: -10 }}

add_years

{{ startdate | add_years: 3 }}
{{ startdate | add_years: -1 }}

add_months filter

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

add_months: Integer operand

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 }}
{{ startdate | add_seconds: -10239 }}

add_minutes

{{ startdate | add_minutes: 3 }}
{{ startdate | add_minutes: -180 }}

add_hours

{{ startdate | add_hours: 3 }}
{{ startdate | add_hours: -32 }}

add_days

{{ startdate | add_days: 3 }}
{{ startdate | add_days: -2 }}

add_weeks

{{ startdate | add_weeks: 3 }}
{{ startdate | add_weeks: -7 }}

add_months

{{ startdate | add_months: 3 }}
{{ startdate | add_months: -10 }}

add_years

{{ startdate | add_years: 3 }}
{{ startdate | add_years: -1 }}

add_weeks filter

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

add_weeks: Integer operand

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 }}
{{ startdate | add_seconds: -10239 }}

add_minutes

{{ startdate | add_minutes: 3 }}
{{ startdate | add_minutes: -180 }}

add_hours

{{ startdate | add_hours: 3 }}
{{ startdate | add_hours: -32 }}

add_days

{{ startdate | add_days: 3 }}
{{ startdate | add_days: -2 }}

add_weeks

{{ startdate | add_weeks: 3 }}
{{ startdate | add_weeks: -7 }}

add_months

{{ startdate | add_months: 3 }}
{{ startdate | add_months: -10 }}

add_years

{{ startdate | add_years: 3 }}
{{ startdate | add_years: -1 }}

add_hours filter

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

add_hours: Integer operand

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 }}
{{ startdate | add_seconds: -10239 }}

add_minutes

{{ startdate | add_minutes: 3 }}
{{ startdate | add_minutes: -180 }}

add_hours

{{ startdate | add_hours: 3 }}
{{ startdate | add_hours: -32 }}

add_days

{{ startdate | add_days: 3 }}
{{ startdate | add_days: -2 }}

add_weeks

{{ startdate | add_weeks: 3 }}
{{ startdate | add_weeks: -7 }}

add_months

{{ startdate | add_months: 3 }}
{{ startdate | add_months: -10 }}

add_years

{{ startdate | add_years: 3 }}
{{ startdate | add_years: -1 }}

add_days filter

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

add_days: Integer operand

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 }}
{{ startdate | add_seconds: -10239 }}

add_minutes

{{ startdate | add_minutes: 3 }}
{{ startdate | add_minutes: -180 }}

add_hours

{{ startdate | add_hours: 3 }}
{{ startdate | add_hours: -32 }}

add_days

{{ startdate | add_days: 3 }}
{{ startdate | add_days: -2 }}

add_weeks

{{ startdate | add_weeks: 3 }}
{{ startdate | add_weeks: -7 }}

add_months

{{ startdate | add_months: 3 }}
{{ startdate | add_months: -10 }}

add_years

{{ startdate | add_years: 3 }}
{{ startdate | add_years: -1 }}

add_seconds filter

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

add_seconds: Integer operand

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 }}
{{ startdate | add_seconds: -10239 }}

add_minutes

{{ startdate | add_minutes: 3 }}
{{ startdate | add_minutes: -180 }}

add_hours

{{ startdate | add_hours: 3 }}
{{ startdate | add_hours: -32 }}

add_days

{{ startdate | add_days: 3 }}
{{ startdate | add_days: -2 }}

add_weeks

{{ startdate | add_weeks: 3 }}
{{ startdate | add_weeks: -7 }}

add_months

{{ startdate | add_months: 3 }}
{{ startdate | add_months: -10 }}

add_years

{{ startdate | add_years: 3 }}
{{ startdate | add_years: -1 }}
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 %}).

Datetime

{{ datetime }}

A field containing a user-selected date

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.

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 }}
{{ startdate | add_seconds: -10239 }}

add_minutes

{{ startdate | add_minutes: 3 }}
{{ startdate | add_minutes: -180 }}

add_hours

{{ startdate | add_hours: 3 }}
{{ startdate | add_hours: -32 }}

add_days

{{ startdate | add_days: 3 }}
{{ startdate | add_days: -2 }}

add_weeks

{{ startdate | add_weeks: 3 }}
{{ startdate | add_weeks: -7 }}

add_months

{{ startdate | add_months: 3 }}
{{ startdate | add_months: -10 }}

add_years

{{ startdate | add_years: 3 }}
{{ startdate | add_years: -1 }}

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 }}
{{ "2009-09-09" | date: "D" }}
{{ 0 | date: "D" }}
{{ 1756239994 | date: "D" }}

Defaults to the current date

{{"now" | date}}

format a date as a string

{{request.date | date: "d"}}
{{request.date | date: "D"}}
{{request.date | date: "o"}}
{{request.date | date: "MMMM dd, yyyy"}}

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

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" %}

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"}}
{{request.date | format: "D"}}
{{request.date | format: "o"}}
{{request.date | format: "MMMM dd, yyyy"}}

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.

To timezone filter

Copy
{{ article.post_date | to_timezone: session.user_timezone }}

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

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 }}
{{ "2009-09-09" | date: "D" }}
{{ 0 | date: "D" }}
{{ 1756239994 | date: "D" }}

Defaults to the current date

{{"now" | date}}

format a date as a string

{{request.date | date: "d"}}
{{request.date | date: "D"}}
{{request.date | date: "o"}}
{{request.date | date: "MMMM dd, yyyy"}}

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" }}
{{ diff | format: "dd 'days'" }}

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

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: "Europe/Rome"). If full is false (default) or not specified and an abbreviated timezone name is available returns the abbreviated timezone name (eg: "PST" or "PDT").

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}}
{{request.date | add_months: 6 | timezone}}
{{request.date | timezone: true}}

to_timezone filter

Converts a date to the specified timezone.

to_timezone: String timezone

Examples

Use the to_timezone filter to convert a date to a specific timezone.

Using the to_timezone filter

Copy
{{request.date | to_timezone: 'UTC'}}
{{request.date | to_timezone: 'Europe/Rome'}}

add_minutes filter

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

add_minutes: Integer operand

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 }}
{{ startdate | add_seconds: -10239 }}

add_minutes

{{ startdate | add_minutes: 3 }}
{{ startdate | add_minutes: -180 }}

add_hours

{{ startdate | add_hours: 3 }}
{{ startdate | add_hours: -32 }}

add_days

{{ startdate | add_days: 3 }}
{{ startdate | add_days: -2 }}

add_weeks

{{ startdate | add_weeks: 3 }}
{{ startdate | add_weeks: -7 }}

add_months

{{ startdate | add_months: 3 }}
{{ startdate | add_months: -10 }}

add_years

{{ startdate | add_years: 3 }}
{{ startdate | add_years: -1 }}

add_years filter

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

add_years: Integer operand

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 }}
{{ startdate | add_seconds: -10239 }}

add_minutes

{{ startdate | add_minutes: 3 }}
{{ startdate | add_minutes: -180 }}

add_hours

{{ startdate | add_hours: 3 }}
{{ startdate | add_hours: -32 }}

add_days

{{ startdate | add_days: 3 }}
{{ startdate | add_days: -2 }}

add_weeks

{{ startdate | add_weeks: 3 }}
{{ startdate | add_weeks: -7 }}

add_months

{{ startdate | add_months: 3 }}
{{ startdate | add_months: -10 }}

add_years

{{ startdate | add_years: 3 }}
{{ startdate | add_years: -1 }}

add_months filter

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

add_months: Integer operand

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 }}
{{ startdate | add_seconds: -10239 }}

add_minutes

{{ startdate | add_minutes: 3 }}
{{ startdate | add_minutes: -180 }}

add_hours

{{ startdate | add_hours: 3 }}
{{ startdate | add_hours: -32 }}

add_days

{{ startdate | add_days: 3 }}
{{ startdate | add_days: -2 }}

add_weeks

{{ startdate | add_weeks: 3 }}
{{ startdate | add_weeks: -7 }}

add_months

{{ startdate | add_months: 3 }}
{{ startdate | add_months: -10 }}

add_years

{{ startdate | add_years: 3 }}
{{ startdate | add_years: -1 }}

add_weeks filter

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

add_weeks: Integer operand

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 }}
{{ startdate | add_seconds: -10239 }}

add_minutes

{{ startdate | add_minutes: 3 }}
{{ startdate | add_minutes: -180 }}

add_hours

{{ startdate | add_hours: 3 }}
{{ startdate | add_hours: -32 }}

add_days

{{ startdate | add_days: 3 }}
{{ startdate | add_days: -2 }}

add_weeks

{{ startdate | add_weeks: 3 }}
{{ startdate | add_weeks: -7 }}

add_months

{{ startdate | add_months: 3 }}
{{ startdate | add_months: -10 }}

add_years

{{ startdate | add_years: 3 }}
{{ startdate | add_years: -1 }}

add_hours filter

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

add_hours: Integer operand

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 }}
{{ startdate | add_seconds: -10239 }}

add_minutes

{{ startdate | add_minutes: 3 }}
{{ startdate | add_minutes: -180 }}

add_hours

{{ startdate | add_hours: 3 }}
{{ startdate | add_hours: -32 }}

add_days

{{ startdate | add_days: 3 }}
{{ startdate | add_days: -2 }}

add_weeks

{{ startdate | add_weeks: 3 }}
{{ startdate | add_weeks: -7 }}

add_months

{{ startdate | add_months: 3 }}
{{ startdate | add_months: -10 }}

add_years

{{ startdate | add_years: 3 }}
{{ startdate | add_years: -1 }}

add_days filter

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

add_days: Integer operand

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 }}
{{ startdate | add_seconds: -10239 }}

add_minutes

{{ startdate | add_minutes: 3 }}
{{ startdate | add_minutes: -180 }}

add_hours

{{ startdate | add_hours: 3 }}
{{ startdate | add_hours: -32 }}

add_days

{{ startdate | add_days: 3 }}
{{ startdate | add_days: -2 }}

add_weeks

{{ startdate | add_weeks: 3 }}
{{ startdate | add_weeks: -7 }}

add_months

{{ startdate | add_months: 3 }}
{{ startdate | add_months: -10 }}

add_years

{{ startdate | add_years: 3 }}
{{ startdate | add_years: -1 }}

add_seconds filter

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

add_seconds: Integer operand

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 }}
{{ startdate | add_seconds: -10239 }}

add_minutes

{{ startdate | add_minutes: 3 }}
{{ startdate | add_minutes: -180 }}

add_hours

{{ startdate | add_hours: 3 }}
{{ startdate | add_hours: -32 }}

add_days

{{ startdate | add_days: 3 }}
{{ startdate | add_days: -2 }}

add_weeks

{{ startdate | add_weeks: 3 }}
{{ startdate | add_weeks: -7 }}

add_months

{{ startdate | add_months: 3 }}
{{ startdate | add_months: -10 }}

add_years

{{ startdate | add_years: 3 }}
{{ startdate | add_years: -1 }}
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 %}).

Set_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.

Some dates and times do not use the default timezone and will not be affected by this method.

Examples

Set Timezone by String

Copy
{% set_timezone "America/Indianapolis" %}

Set Timezone with string manipulation

Copy
{% var cityname = "Amsterdam" %}
{% set_timezone "Europe/" | append: cityname %}

Examples

Set Timezone with string manipulation

Copy
{% var cityname = "Amsterdam" %}
{% set_timezone "Europe/" | append: cityname %}

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 }}
{{ "2009-09-09" | date: "D" }}
{{ 0 | date: "D" }}
{{ 1756239994 | date: "D" }}

Defaults to the current date

{{"now" | date}}

format a date as a string

{{request.date | date: "d"}}
{{request.date | date: "D"}}
{{request.date | date: "o"}}
{{request.date | date: "MMMM dd, yyyy"}}

Set Timezone by String

Copy
{% set_timezone "America/Indianapolis" %}

Time Diff

{{ time_diff }}

Contains information about the difference between two dates.

Name Type Description
is_valid Boolean Will always be true
days Integer The number of days between the two dates
hours Integer The hours component of the difference between the two dates (eg: if the dates are 25 hours apart this will be 1 since they are 1 day and 1 hour apart)
minutes Integer 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)
seconds Integer 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)
total_days Number The total difference between the two dates expressed as whole and fractional days (eg: 25 hours apart would be 1.042 days)
total_hours Number The total difference between the two dates expressed as whole and fractional hours (eg: 1 day and 90 minutes apart would be 25.5 hours)
total_minutes Number The total difference between the two dates expressed as whole and fractional minutes (eg: 90 minutes, and 10 seconds apart would be 90.167 minutes)
total_seconds Number 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)
output String 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)

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" }}
{{ diff | format: "dd 'days'" }}

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

Examples

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

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" }}
{{ diff | format: "dd 'days'" }}

Time

{{ time }}

Represents a specific instant in a specific timezone.

Name Type Description
is_valid Boolean Will always be true
is_future Boolean 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
year Integer The calendar year
month Number The calendar month (1-12)
day Integer The calendar day of the month (1-31)
day_of_year Integer The day of the year (1-366)
day_of_week Integer The day of the week (Monday = 1, Sunday = 7)
hour Integer The hour of the day (0-23)
minute Integer The minute of the hour (0-59)
second Integer The second of the minute (0-59)
offset time_diff The utc offset of the timezone at this instant expressed as a time_diff (ranging from -14 to +14 hours)
timezone String The full timezone identifier
timezone_short String 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)
output String The instant output using the ISO 8601 standard (yyyy-MM-ddTHH:mm:ss.fffffff)

Examples

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.

Set Timezone with string manipulation

Copy
{% var cityname = "Amsterdam" %}
{% set_timezone "Europe/" | append: cityname %}

Set Timezone by String

Copy
{% set_timezone "America/Indianapolis" %}

Timezone

{{ timezone }}

Name Type Description
is_valid Boolean True if the value is a valid timezone string
value String timezone string
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 timezone string. May include additional markup in the editor preview to make it easier to edit content

Stores the timezone that should be used when displaying a date and/or time.

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

Some dates and times do not use the default timezone and will not be affected by this method.

Examples

Set Timezone by String

Copy
{% set_timezone "America/Indianapolis" %}

Set Timezone with string manipulation

Copy
{% var cityname = "Amsterdam" %}
{% set_timezone "Europe/" | append: cityname %}

to_timezone filter

Converts a date to the specified timezone.

to_timezone: String timezone

Examples

Use the to_timezone filter to convert a date to a specific timezone.

Using the to_timezone filter

Copy
{{request.date | to_timezone: 'UTC'}}
{{request.date | to_timezone: 'Europe/Rome'}}

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: "Europe/Rome"). If full is false (default) or not specified and an abbreviated timezone name is available returns the abbreviated timezone name (eg: "PST" or "PDT").

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}}
{{request.date | add_months: 6 | timezone}}
{{request.date | timezone: true}}

Examples

Set Timezone with string manipulation

Copy
{% var cityname = "Amsterdam" %}
{% set_timezone "Europe/" | append: cityname %}

To timezone filter

Copy
{{ article.post_date | to_timezone: session.user_timezone }}

To timezone filter with formatting

Copy
{% if entity.alt_timezone.is_valid %}
{{ entity.alt_date | to_timezone: entity.alt_timezone | date: 'f' }}
{% endif %}

Use the to_timezone filter to convert a date to a specific timezone.

Using the to_timezone filter

Copy
{{request.date | to_timezone: 'UTC'}}
{{request.date | to_timezone: 'Europe/Rome'}}

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}}
{{request.date | add_months: 6 | timezone}}
{{request.date | timezone: true}}

Set Timezone by String

Copy
{% set_timezone "America/Indianapolis" %}

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 }}
{{ startdate | add_seconds: -10239 }}

add_minutes

{{ startdate | add_minutes: 3 }}
{{ startdate | add_minutes: -180 }}

add_hours

{{ startdate | add_hours: 3 }}
{{ startdate | add_hours: -32 }}

add_days

{{ startdate | add_days: 3 }}
{{ startdate | add_days: -2 }}

add_weeks

{{ startdate | add_weeks: 3 }}
{{ startdate | add_weeks: -7 }}

add_months

{{ startdate | add_months: 3 }}
{{ startdate | add_months: -10 }}

add_years

{{ startdate | add_years: 3 }}
{{ startdate | add_years: -1 }}

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 }}
{{ "2009-09-09" | date: "D" }}
{{ 0 | date: "D" }}
{{ 1756239994 | date: "D" }}

Defaults to the current date

{{"now" | date}}

format a date as a string

{{request.date | date: "d"}}
{{request.date | date: "D"}}
{{request.date | date: "o"}}
{{request.date | date: "MMMM dd, yyyy"}}