Skip to main content

Date element

This is a rich text element, compatible only with the rich_text block. It must be used within the rich_text_list, rich_text_quote, or rich_text_section block element within the rich_text block's elements array.

Fields

FieldTypeDescriptionRequired?
typeStringThe type of object; in this case "date".Required
timestampNumberA Unix timestamp for the date to be displayed in seconds.Required
formatStringA template string containing curly-brace-enclosed tokens to substitute your provided timestamp. See details below.Required
timezoneStringThe timezone in which the date is in.Optional
urlStringURL to link the entire format string to.Optional
fallbackStringText to display in place of the date should parsing, formatting or displaying fail.Optional
styleObjectAn object of optional boolean properties that dictate style: bold, italic, strike, highlight, client_highlight, and underline.Optional

Date format strings

The following are the template strings allowed by the format property of the date element type.

  • {day_divider_pretty}: Shows today, yesterday or tomorrow if applicable. Otherwise, if the date is in current year, uses the {date_long} format without the year. Otherwise, falls back to using the {date_long} format.
  • {date_num}: Shows date as YYYY-MM-DD.
  • {date_slash}: Shows date as DD/MM/YYYY (subject to locale preferences).
  • {date_long}: Shows date as a long-form sentence including day-of-week, e.g. Monday, December 23rd, 2013.
  • {date_long_full}: Shows date as a long-form sentence without day-of-week, e.g. August 9, 2020.
  • {date_long_pretty}: Shows yesterday, today or tomorrow, otherwise uses the {date_long} format.
  • {date}: Same as {date_long_full} but without the year.
  • {date_pretty}: Shows today, yesterday or tomorrow if applicable, otherwise uses the {date} format.
  • {date_short}: Shows date using short month names without day-of-week, e.g. Aug 9, 2020.
  • {date_short_pretty}: Shows today, yesterday or tomorrow if applicable, otherwise uses the {date_short} format.
  • {time}: Depending on user preferences, shows just the time-of-day portion of the timestamp using either 12 or 24 hour clock formats, e.g. 2:34 PM or 14:34.
  • {time_secs}: Depending on user preferences, shows just the time-of-day portion of the timestamp using either 12 or 24 hour clock formats, including seconds, e.g. 2:34:56 PM or 14:34:56.
  • {ago}: A human-readable period of time, e.g. 3 minutes ago, 4 hours ago, 2 days ago.

Example

{
"blocks": [
{
"type": "rich_text",
"elements": [
{
"type": "rich_text_section",
"elements": [
{
"type": "date",
"timestamp": 1720710212,
"format": "{date_num} at {time}",
"fallback": "timey"
}
]
}
]
}
]
}

View in Block Kit Builder