Skip to content

dateAndTime

dateAndTime fields provide subfields for entering date and time values in a user-friendly way. Dates and times are stored in ISO 8601 format, for example: 2022-01-01T03:00:00Z.

Note that while dates and times are edited in the individual editor's time zone, they are always saved in UTC (Universal Coordinated Time).

Module field definition

javascript
// Configuring the `eventDateAndTime` field in a module's `fields.add` subsection:
eventDateAndTime: {
  label: 'What is the date and time of the event?',
  type: 'dateAndTime'
}

Settings

Required

PropertyTypeDefaultDescription
labelStringn/aSets the visible label for the field in the UI
typeStringn/aSpecifies the field type (string for this type)

Optional

PropertyTypeDefaultDescription
helpStringn/aHelp text for the content editor
htmlHelpStringn/aHelp text with support for HTML markup
ifObject{}Conditions to meet before the field is active. See the guide for details.
requiredIfObject{}Conditions to meet before the field is required. See the guide for details.
hiddenBooleanfalseIf true, the field is hidden
requiredBooleanfalseIf true, the field is mandatory
readOnlyBooleanfalseIf true, prevents the user from editing the field value

Use in templates

Times are stored, and will print, in the ISO 8601 format YYYY-MM-DDTHH:MM:SSZ.

To print them in the format of your choice pass a momentjs/datejs compliant format string to the date Nunjucks filter, like this:

nunjucks
{{ data.piece.eventDateAndTime | date("dddd, MMMM Do YYYY, h:mm:ss a") }}