I have this type of date:
"Date": "2024-09-06T06:58:19.326Z",
How should I validate it in my FormRequest in Laravel?
I've tried this:
'required|date_format:Y-m-d\TH:i:s.u\Z'
and this:
date_format:Y-m-d
but I get 422 every time.
u
from the date format represents microseconds (6 digits). To match your datetime format you need to use v
which represents only milliseconds (3 digits).
Therfor the solution would be:
'required|date_format:Y-m-d\TH:i:s.v\Z'