Timezone

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