# Date Fields
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:
use Laravel\Nova\Fields\Date;
use Laravel\Nova\Fields\DateTime;
Date::make('Birthday');
DateTime::make('Created At');
# Timezones
By default, Nova users will always see dates presented in their local timezone based on their browser's locale information.
In addition, users may always set dates in their local timezone. The dates will automatically be converted to your application's "server-side" timezone as defined by the timezone
option in your app
configuration file.
# Customizing The Timezone
Sometimes you may wish to explicitly define the Nova user's timezone instead of using the browser's locale information. 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
:
use Laravel\Nova\Nova;
use Illuminate\Http\Request;
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
parent::boot();
Nova::userTimezone(function (Request $request) {
return $request->user()->timezone;
});
}
# Customizing The First Day of the Week
By default, Nova's Date and DateTime fields recognize Sunday as the first day of the week (as the United States, Canada, and Japan do). If you wish to customize this to follow the international standard ISO 8601
, you can set the firstDayOfWeek
option on the field:
Date::make('Birthday')->firstDayOfWeek(1);
DateTime::make('Created At')->firstDayOfWeek(1);
← Authorization Fields →