Date Fields
Date fields allow you to collect and display date and time information.
Nova offers two types of date fields: Date
and DateTime
. As you may have guessed, the Date
field does not store time information while the DateTime
field does:
Options
Steps
By default, Nova will set a minimum “step” of 1 day for Date
fields and 1 second for DateTime
fields. You may modify the “step” value for both of these fields by providing an integer or Carbon\CarbonInterval
to the field’s step
methods:
Minimum and Maximum Values
Sometimes you may wish to explicitly define minimum and maximum values for Date
or DateTime
fields. This can be done by passing a valid date expression, a date format supported by strtotime
, or an instance of Carbon\CarbonInterface
to the min
and max
methods of these fields:
Timezones
By default, Nova users will always see dates presented in your application’s “server-side” timezone as defined by the timezone
configuration option in your application’s config/app.php
configuration file.
Customizing the Timezone
Sometimes you may wish to explicitly define the Nova user’s timezone instead of using the application’s timezone configuration. For example, perhaps your application allows users to select their own timezone so that they always see consistent date timezones even when traveling around the world.
To accomplish this, you may use the Nova::userTimezone
method. Typically you should call this method in the boot
method of your application’s NovaServiceProvider
:
Was this page helpful?