How are you using it? Query + usage
Feb 19, 2023
9
Level 63
Date casting in a model
Hello,
I have a little problem with the date casting in a model.
protected $casts = [
'payment_date' => 'date:Y-m-d',
];
The casting helps to format the property when I get it, for example with $book->payment_date.
I have specified the format Y-m-d, but when I display the value in the view, it show 2023-02-19 00:00:00.
The problem is that I only want the date and not the time. Effectively if I want to display this datetime in a date type input, it doesn't work.
I probably do something wrong, but I don't see what.
Or perhaps in that case it is necessary to write an accessor ?
Can you help me ?
Thanks a lot.
Vincent
Please or to participate in this conversation.