Skip to content

Date

The Date object represents date.

classDiagram
  direction LR
  Date --> TimeDifference
  class TimeDifference{
  }
  class Date{
    string iso8601
    TimeDifference timeDifference
    string date
    string dateLong
    string dateShort
    int timeInSeconds
    int day
    int dayOfYear
    int month
    string monthName
    string monthNameShort
    int week
    string weekday
    string weekdayShort
    int weekdayDigit
    int year
    int timestamp
  }

It is possible to render the date by rendering the object directly.

source
{{ date }}
output
13-04-2022

Properties

Attribute name Type Description
iso8601 string The ISO 8601 formatted time string
timeDifference TimeDifference The TimeDifference object that represents the difference between 2 moments in time.
date string Formatted date
longDate string Formatted long date
shortDate string Formatted short date
timeInSeconds int Date representation in seconds (the same as timestamp) converted using shop's timezone
day int Day number in month (from 1 to 31)
dayOfYear int Day number in year (from 1 to 366)
month int Month number in year (from 1 to 12)
monthName string Month name
monthNameShort string Month short name
week int Week number in year (from 1 to 53)
weekday string Weekday name
weekdayShort string Weekday short name
weekdayDigit int Weekday digit (from 1 as monday to 7 as sunday)
year int Year
timestamp int Date representation in seconds converted using shop's timezone

Example

iso8601 property

{{ date.iso8601 }}
2022-04-13

timeDifference property

{% set timeA = ObjectApi.getDate("2022-09-01") %}
{% set timeB = ObjectApi.getDate("2022-09-02") %}

{% set diff = timeA.timeDifference(timeB) %}
{{ diff.timeInSeconds }}
86400

date property

{% set date = ObjectApi.getDate("2022-09-01") %}
{{ date.date }}
1 september 2022

dateLong property

{% set date = ObjectApi.getDate("2022-09-01") %}
{{ date.dateLong }}
thursday, 1 september 2022

dateShort property

{% set date = ObjectApi.getDate("2022-09-01") %}
{{ date.dateShort }}
13-04-2022

timeInSeconds property

{% set date = ObjectApi.getDate("2022-09-01") %}
{{ date.timeInSeconds }}
1661990400

day property

{% set date = ObjectApi.getDate("2022-09-01") %}
{{ date.day }}
1

dayOfYear property

{% set date = ObjectApi.getDate("2022-09-01") %}
{{ date.dayOfYear }}
244

month property

{% set date = ObjectApi.getDate("2022-09-01") %}
{{ date.month }}
9

monthName property

{% set date = ObjectApi.getDate("2022-09-01") %}
{{ date.monthName }}
september

monthNameShort property

{% set date = ObjectApi.getDate("2022-09-01") %}
{{ date.monthNameShort }}
sep.

week property

{% set date = ObjectApi.getDate("2022-09-01") %}
{{ date.week }}
35

weekday property

{% set date = ObjectApi.getDate("2022-09-01") %}
{{ date.weekday }}
thursday

weekdayShort property

{% set date = ObjectApi.getDate("2022-09-01") %}
{{ date.weekdayShort }}
thu.

weekdayDigit property

{% set date = ObjectApi.getDate("2022-09-01") %}
{{ date.weekdayDigit }}
4

year property

{% set date = ObjectApi.getDate("2022-09-01") %}
{{ date.year }}
2022

timestamp property

{% set date = ObjectApi.getDate("2022-09-01") %}
{{ date.timestamp }}
1661990400