Time

Time

{{ time }}

Represents a specific instant in a specific timezone.

Properties of {{ time }} objects
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)

Related

{{ form_submit }}

{{ timezone }}

{{ client }}

The client object is available on every page, and contains information about the history of the browser used to access the site. Note that most of these properties are only meaningful if the user has allowed permission for sessions. Additionally, client properties require cookies in order to work. Requests made without cookies (such as by bots or browsers with cookies disabled) or without permission for session will always behave like an initial page-load without existing client information. The client object is one of a handful of simple mechanisms to enable personalization on your site. Used well, these can be powerful tools for developers and website owners.

{{ date }}

A field containing a user-selected date

{{ request }}

The request object is available on every page, and contains information regarding the HTTP request that may be useful for serving and rendering the page.

{{ permission }}

An object containing information about permission allowed or denied in the permissions system and accessed using the {{ client_permissions }} object.

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

{{ date_field }}

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

{{ datetime }}

A field containing a user-selected date

number

Can be any number, including integers, decimals, or the value 0. Any value - including 0 - evaluates as true when used alone in a conditional.

{{ profile }}

{{ page_view }}

An object containing information about a previous request in the current session

{{ auth }}

Stores information about the current state of profile authorization, which is the result of calls to the {% auth %} methods.

{{ time_diff }}

Contains information about the difference between two dates.

{{ calendar }}

integer

A whole (non-fractional, non-decimal) number. May be 0. Any value - including 0 - evaluates as true when used alone in a conditional.

{{ client_permissions }}

The client_permissions object is available on every page, and contains information about whether or not the user (or developer) has granted permission to use specific features. By default the only feature controlled by this is sessions, but the permission system may be "extended" arbitrarily by the developer to control additional features. The permissions feature requires cookies in order to work. Requests made without cookies (such as by bots or browsers with cookies disabled) will always behave like an initial page-load without existing permission information.

Examples

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 how to set Timezone by String.

Set the request timezone

Copy
{%- set_timezone "America/Indianapolis" -%}
{{- request.date | timezone }}
America/Indianapolis
{%- var cityname = "Amsterdam" -%}
{%- set_timezone "Europe/" | append: cityname -%}
{{- request.date | timezone }}
Europe/Amsterdam