Date Variables

The date variables give access to certain date values. You can even set your own date values. You can also use the date variable with the date filter to output a formatted date.

Built-in date values

The following values are available:

Variable Description
_core.date.day

Holds the day of the month value as a number. It will be two digits with a leading zero if necessary. Examples:

  • 05
  • 19

{{ _core.date.day }}

If you need the day of the week value use {{ _core.date.weekday }}

_core.date.isWeekday

Holds whether the current day is a weekday (Monday, Tuesday, Wednesday, Thursday, or Friday).

This is a boolean value.

{% if _core.date.isWeekday %}
<p>Today is a weekday.</p>
{% endif %}

_core.date.isWeekend

Holds whether the current day is a weekend day (Saturday or Sunday).

This is a boolean value.

{% if _core.date.isWeekend %}
<p>Today is not a weekday. It's the weekend!</p>
{% endif %}

_core.date.month

Holds the month value as a number. It will be two digits with a leading zero if necessary. Examples:

  • 05
  • 11

{{ _core.date.month }}

_core.date.monthName

Holds the full name of the month. Examples:

  • February
  • March
  • June

{{ _core.date.monthName }}

_core.date.timestamp

Holds the numeric timestamp, which is the number of seconds since the Unix Epoch (January 1, 1970, 00:00:00 GMT).

{{ _core.date.timestamp }}

_core.date.weekday

Holds the full name of the current day of the week. Examples:

  • Monday
  • Thursday
  • Saturday

{{ _core.date.weekday }}

_core.date.weekdayNumber

Holds the day of the week as a number. For example:

  • 1
  • 5

{{ _core.date.weekdayNumber }}

The numbers correspond to the day of the week, starting with Sunday.

  • 1:  Sunday
  • 2:  Monday
  • 3: Tuesday
  • 4: Wednesday
  • 5: Thursday
  • 6: Friday
  • 7: Saturday
_core.date.year

Holds the numeric year for the current date as four digits. Examples:

  • 2021
  • 2022

{{ _core.date.year }}

Set your own date values

You can set your own date values and reuse them later in the template.

{% set _core.date.today = 'now'|date('M d, Y') %}
... [Further down in the template ]
<p>Today is {{ _core.date.today }}</p>

Display the date with the date filter

If you need to get a custom date format for the current date then you can either use the special "now" value with the date filter, or you can use _core.date with the date filter.

Display the date a MONTH DAY, YEAR
{{ _core.date|date('F d, Y') }}