I have a Nova "Date" field and it's working fine it shows the current date when the page is accessed at first.
However, if the user selects the date picker and change the date it appears always the same date "2022/0/5" that is incorrect its not the date that the user selected. On the db stores correctly like "2022-06-12".
Do you know where can be the issue?
new Panel('Comments', [
...JSON::make('Comments', [
Text::make('Title'),
Date::make('Date')
->format('Y/m/d')
->resolveUsing(function ($value) {
return Carbon::now()->format('Y/m/d');
})
])->data
]),
Model:
class Settings extends Model
{
use HasFactory;
protected $casts = [
'notes' => 'array',
];
}
Try this instead
new Panel('Comments', [
...JSON::make('Comments', [
Text::make('Title'),
Date::make('Date')
->format('Y/M/d') // M refers to month
->resolveUsing(function ($value) {
return Carbon::now()->format('Y/M/d');
})
])->data
]),
The format which you have used is Y/m/d
-> m refers to minutes
instead use Y/M/d
-> M refers to month