Date and Time Field

Illustrated drawing of Amadeus Maxmimilian StadlerIllustrated drawing of Amadeus Maxmimilian Stadler

Amadeus Stadler

Last updated August 31, 2021

The Date and Time field allows adding dates and timestamps to your content. Ideal for creation and publishing dates, as well as appointments and other events.

Editing UI Widget

This field is displayed as a button which opens a calendar widget, allowing you to select a date and a time (if the showTime option is enabled). The field is labelled by its label and shows the currently selected date and time in a human readable format, as well as a button to reset the value to null if the removable option is enabled.

Output Format

The Unformatted Text field outputs the text as a string or number depending on which outputFormat is selected.

Options

The following options are available for this field (default values shown):

{
  "outputFormat": "iso",
  "removable": false,
  "showTime": true,
  "defaultToNow": true,
  "useAsUpdatedAt": false,
  "only": null
}
  • outputFormat: dates can either be stored as ISO-formatted strings or UNIX timestamps, i.e. the number of seconds that has passed since Jan. 1st 1970

  • removable: whether or not the set date may be removed, resetting the value of the field to null

  • showTime: whether to show a time selector in addition to the date selector

  • defaultToNow: if set to true the default value of the field will be the time the content item was created by default

  • useAsUpdatedAt: if set to true the field will be set to the current date and time whenever the content item being edited is saved, unless it is the first time it is being edited, determined by the presence of the ___mb_unedited field, or it is a draft. Date fields with this option enabled will override any date input by the user and will not be validated, so you likely want to mark it as hidden as well.

  • only: if set to either “past” or “future” controls whether only dates in the future or past may be selected respectively

Validation

The following validation options are available for this field (default values shown):

{
  "max": null,
  "min": null,
  "required": false,
  "unit": "date",
  "isString": true
}

Notes

A hidden Date and Time field with defaultToNow set to true is a great way to have a record of when a particular content item was created.

If the outputFormat is set to "iso", the time string will be in the timezone of the user editing the file.

Version History

  • Version at launch: 2