Reference

Guide

Date

A date picker field

The date field generates a simple input with a nice date picker. It can be setup to display and store dates.

Example

fields:
  published:
    label: Published on
    type: date

Field properties

Property Type Default Description
after

Optional text that will be shown after the input

autofocus bool

Sets the focus on this field when the form loads. Only the first field with this label gets

before

Optional text that will be shown before the input

default

Default date when a new page/file/user gets created

disabled bool

If true, the field is no longer editable and will not be saved

format string

Defines a custom format that is used when the field is saved

help

Optional help text below the field

icon string calendar

Changes the calendar icon to something custom

label

The field label can be set as string or associative array with translations

max string

Youngest date, which can be selected/saved

min string

Oldest date, which can be selected/saved

required bool

If true, the field has to be filled in correctly to be saved.

time false

Pass true or an array of time field options to show the time selector.

translate bool true

If false, the field will be disabled in non-default languages and cannot be translated. This is only relevant in multi-language setups.

when

Conditions when the field will be shown (since 3.1.0)

width string 1/1

The width of the field in the field grid. Available widths: 1/1, 1/2, 1/3, 1/4, 2/3, 3/4

How to use in templates/snippets

To convert the value to a date object, use the toDate() method:

<?= $page->published()->toDate() ?>