Adding a Smart Date field

Last updated on
21 July 2021

When adding a new smart date range field, the first step is to specify the allowed number of values. As with most fields, you can choose to allow only a single value, or multiples values (potentially with a maximum number).

On the settings page, you can assign any help text, but the main key section is in the default settings.

The Default date allows you to specify if a date should be automatically assigned to a new content entity. As with core you can have it use the current date and time ("Current date"), or an offset from the current time ("Relative date") by specifying an offset, for example "+1 day". Smart Date provides an additional option ("Next hour") which will default to the start of the next hour, e.g. 11 a.m., if the current time is 10:17 a.m.

Next is the field to specify Allowed duration increments. This works similar to core's list fields, where each line will be an option in the duration select. A simple number will be used as both value and label (with " minutes" appended), or you can add a custom label with a pipe character separating the value and label. You can allow for a zero duration, if you want editors to create ranges that effectively a moment in time. The only non-numeric value that is accepted is "custom", which allows an editor to specify a range of an arbitrary duration.

Finally, you can specify Default duration, which must be one of the values in the Allowed duration increments above.

Some additional notes:

  • If only a duration of zero is allowed, the end date and time fields will never be displayed
  • Smart Date stores all day ranges as starting at 12 a.m. and ending at 11:59 p.m. By default Smart Date will add an "all day" checkbox, but needs to have an allowed duration that allows this, either 1439 (this range in minutes) or custom, before it will add the checkbox

Help improve this page

Page status: No known problems

You can: