Studio

Datetime

The schema type for expressing an exact date and time.

An ISO-8601 formatted string containing date and time stored in UTC. E.g. 2017-02-12T09:15:00.000Z. See the DatetimeDefinition reference for the full type definition.

The date+time is represented as a string in a simplified extended ISO format (ISO 8601). This is the same format as date.toISOString() and date.toJSON() returns, so the stored value always carries milliseconds.

Properties

  • Requiredtype

    Value must be set to datetime.

  • Requiredname

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

  • Human readable label for the field.

  • If set to true, this field will be hidden in the studio. You can also return a callback function to use it as a conditional field.

  • If set to true, this field will not be editable in the content studio. You can also return a callback function to use it as a conditional field.

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

  • Placeholder text shown in the input when it has no value.

  • The initial value used when creating new values of this type. Can be a literal value, or a resolver function that returns a literal value or a promise that resolves to one.

  • Lets you provide custom components to override the studio defaults in various contexts. The available keys are diff, field, input, item, and preview. This property is in beta.

  • Marks a field or document type as deprecated in the studio interface and displays a user-defined message defined by the single required reason property.

    If you deploy a GraphQL API schema, this property will translated into the @deprecated directive.

  • Supply a custom icon for this field. See Icons for the supported values.

Options (DatetimeOptions)

  • Controls how the date input field formats the displayed date. Default is YYYY-MM-DD.

    The format string is Moment-style, but only this subset of tokens is supported: YYYY, YY, MMMM, MMM, MM, M, DD, D, dddd, ddd, HH, H, hh, h, mm, m, ss, s, A, a. Other tokens, including bracket escaping such as [T], are passed through unconverted and stop the input from parsing what it just rendered.

  • Controls how the time input field formats the displayed time. Default is HH:mm. The same token subset applies as for dateFormat.

    The input joins the two options into a single format string, so an unsupported token in either one stops the whole field from parsing.

  • Number of minutes the time value is rounded to. Defaults to 1.

    The time control accepts any minute as you type, then rounds to the nearest step once the field loses focus. Setting 15, for example, snaps a typed 09:07 back to 09:00.

  • Determines whether the user is allowed to set a personalized time zone for viewing and interacting with the field in Studio. Defaults to true.

    The time zone control only appears when you set allowTimeZoneSwitch: true or displayTimeZone explicitly. A field that sets neither shows no time zone control, even though the option defaults to true.

  • Set a specific time zone to be used when viewing and interacting with the field in Studio. Expects a string in the shape of a valid time zone identifier. Note: the timestamp stored in the dataset is always UTC.

Validation (DatetimeRule)

  • Ensures that this field exists.

  • Discards the validation rules set before it in the chain and makes the field optional. Rules chained after it still apply.

  • Minimum date (inclusive). Accepts an ISO 8601 date string, or a field reference returned by valueOfField().

  • Maximum date (inclusive). Accepts an ISO 8601 date string, or a field reference returned by valueOfField().

  • Creates a custom validation rule.

  • Sets a custom error message for the preceding validation rule.

  • Sets a custom warning message for the preceding validation rule. Warnings do not prevent publishing.

  • Sets a custom info message for the preceding validation rule. Info messages are purely informational and do not prevent publishing.

  • Gets the value of a sibling field to use in validation. Useful for creating validation rules that depend on the value of another field.

Input

Response

Example: All options set

Was this page helpful?