Closed giangnh13579 closed 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)),
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.
Description:
Date
field to the first day of month, but it always displays the last day of the previous month.Date
field:Timezone configuration in
config/app.php
:'timezone' => 'Asia/Ho_Chi_Minh',
which equals to+7
timezoneFor current date is
24-05-2023
, it displays30-04-2023
in the form (create/update/action). When I check the value return in the api response, it shows value30-04-2023 17:00:00
. It seems the time is converted defaultly to UTCFor now, I fix this temporarily by adding 12 hours to the first day of current month:
now()->startOfMonth()->addHours(12)