Static CMS
Star StaticJsCMS/static-cms on GitHub
v4.3.0DocsExamplesDemoCommunity

DateTime

  • Name: datetime
  • UI: Datetime picker
  • Data type: date-fns formatted datetime string

The datetime widget translates a datetime picker to a datetime string.

Widget Options

For common options, see Common widget options.

NameTypeDefaultDescription
defaultstringCurrent Date and TimeOptional. The default value for the field. Accepts a datetime string, or an empty string to accept blank input.
formatstringyyyy-MM-dd'T'HH:mm:ss.SSSXXXOptional. Sets storage format. Accepts date-fns tokens
date_formatstring
| boolean
trueOptional. Sets date display format in UI.
  • string - Accepts date-fns tokens
  • true - Uses default locale format
  • false - If time_format is true or a string, then date picker is hidden
time_formatstring
| boolean
trueOptional. Sets time display format in UI.
  • string - Accepts date-fns tokens
  • true - Uses default locale format
  • false - Hides the time picker
picker_utcbooleanfalseOptional.
  • true - The datetime picker will display times in UTC
  • false - The datetime picker will display times in the user's local timezone
When using date-only formats, it can be helpful to set this to true so users in all timezones will see the same date in the datetime picker

Examples

Date Time Picker

name: 'datetime'
label: 'Datetime'
widget: 'datetime'
date_format: 'dd.MM.yyyy' # e.g. 24.12.2022
time_format: 'HH:mm' # e.g. 21:07
format: 'yyyy-MM-dd HH:mm' # e.g. 2022-12-24 21:07

Date Picker

name: 'date'
label: 'Date'
widget: 'datetime'
date_format: 'dd.MM.yyyy' # e.g. 24.12.2022
time_format: false
format: 'yyyy-MM-dd' # e.g. 2022-12-24

Time Picker

name: 'date'
label: 'Date'
widget: 'datetime'
date_format: false
time_format: 'HH:mm' # e.g. 21:07
format: 'HH:mm' # e.g. 21:07