Overview
The date-time picker provides an interactive interface for selecting a date and/or a time.Customizing the storage format
You may customize the format of the field when it is saved in your database, using theformat() method. This accepts a string date format, using PHP date formatting tokens:
Disabling the seconds input
When using the time picker, you may disable the seconds input using theseconds(false) method:
Timezones
If you’d like users to be able to manage dates in their own timezone, you can use thetimezone() method:
Enabling the JavaScript date picker
By default, Filament uses the native HTML5 date picker. You may enable a more customizable JavaScript date picker using thenative(false) method:
Customizing the display format
You may customize the display format of the field, separately from the format used when it is saved in your database. For this, use thedisplayFormat() method, which also accepts a string date format, using PHP date formatting tokens:
locale() method:
Configuring the time input intervals
You may customize the input interval for increasing/decreasing the hours/minutes /seconds using thehoursStep() , minutesStep() or secondsStep() methods:
Configuring the first day of the week
In some countries, the first day of the week is not Monday. To customize the first day of the week in the date picker, use thefirstDayOfWeek() method on the component. 0 to 7 are accepted values, with Monday as 1 and Sunday as 7 or 0:
Disabling specific dates
To prevent specific dates from being selected:Closing the picker when a date is selected
To close the picker when a date is selected, you can use thecloseOnDateSelection() method:
Autocompleting dates with a datalist
Unless you’re using the JavaScript date picker, you may specify datalist options for a date picker using thedatalist() method:
Focusing a default calendar date
By default, if the field has no state, opening the calendar panel will open the calendar at the current date. This might not be convenient for situations where you want to open the calendar on a specific date instead. You can use thedefaultFocusedDate() to set a default focused date on the calendar:
Adding affix text aside the field
You may place text before and after the input using theprefix() and suffix() methods:
Using icons as affixes
You may place an icon before and after the input using theprefixIcon() and suffixIcon() methods:
Setting the affix icon’s color
Affix icons are gray by default, but you may set a different color using theprefixIconColor() and suffixIconColor() methods:
Making the field read-only
Not to be confused with disabling the field, you may make the field “read-only” using thereadonly() method:
disabled().
There are a few differences, compared to disabled():
- When using
readOnly(), the field will still be sent to the server when the form is submitted. It can be mutated with the browser console, or via JavaScript. You can usedehydrated(false)to prevent this. - There are no styling changes, such as less opacity, when using
readOnly(). - The field is still focusable when using
readOnly().
Date-time picker validation
As well as all rules listed on the validation page, there are additional rules that are specific to date-time pickers.Max date / min date validation
You may restrict the minimum and maximum date that can be selected with the picker. TheminDate() and maxDate() methods accept a DateTime instance (e.g. Carbon), or a string: