laravel / nova-issues

556 stars 34 forks source link

Default value for Date field auto format to UTC time #5568

Closed giangnh13579 closed 1 year ago

giangnh13579 commented 1 year ago

Description:

Date::make(__('From Date'), 'from_date')
    ->rules(['required', 'date'])
    ->default(now()->startOfMonth())
    ->help(__($this->dateFromHelpText)),
crynobone commented 1 year ago

You should be able to do the following:

Date::make(__('From Date'), 'from_date')
    ->rules(['required', 'date'])
    ->default(fn () => now(Nova::resolveUserTimezone($request) ?? null)->startOfMonth())
    ->help(__($this->dateFromHelpText)),
github-actions[bot] commented 1 year ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.