Index
Edit

Datetime

An ISO-8601 formatted string containing date and time stored in UTC. E.g.  2017-02-12T09:15:00Z.

Properties

typestring

Required. Value must be set to datetime.

titlestring

Human readable label for the field.

namestring

Required. The field name. This will be the key in the data record.

hiddenboolean

If set to true, this field will be hidden in the Content Studio.

readOnlyboolean

If set to true, this field will not be editable in the content studio.

descriptionstring

Short description to editors how the field is to be used.

Options

dateFormatstring

Controls how the date input field formats the displayed date. Use any valid Moment format option. Default is YYYY-MM-DD.

timeFormatstring

Controls how the time input field formats the displayed date. Use any valid Moment format option. Default is HH:mm.

timeStepnumber

Number of minutes between each entry in the time input. Default is 15 which lets the user choose between 09:00, 09:15, 09:30 and so on.

calendarTodayLabelstring

Label for the "jump to today" button on the date input widget. Default is today.

The date+time is represented as a string in simplified extended ISO format (ISO 8601). This is the same format as date.toISOString() and date.toJSON() returns.

Pro-tip

If you need to store information about the timezone of the user that edited a certain datetime field, you may want to take a look at the @sanity/rich-date-plugin which provides a richDate type that stores a richer set of data.

Schema
{
  title: 'Launch Scheduled At',
  name: 'launchAt',
  type: 'datetime'
}
JSON output
{
  "launchAt": "2017-02-12T09:15:00Z"
}

Example: All options set

{
  title: 'Launch Scheduled At',
  name: 'launchAt',
  type: 'datetime',
  options: {
    dateFormat: 'YYYY-MM-DD',
    timeFormat: 'HH:mm',
    timeStep: 15,
    calendarTodayLabel: 'Today'
  }
}

Previous: SpanNext: Date