So I am posting to an api controller action, as we can see I have some basic validation:
public function store(Request $request) {
$fields = $request->except(['_token']);
$user = $request->user();
$request->validate([
'log_date' => 'required|date_format:"Y-m-d"',
'bill_time' => 'required|numeric',
]);
}
I constantly get: The log date does not match the format Y-m-d.
The date coming in is formatted by moment js and shows:
"2018-11-6"
So I am confused how is that not formatted properly?
When using
Y-m-d
, thed
on that format mask applies the following:So, the value being passed
2018-11-6
fails due to6
not matching06
. Either useY-m-j
, wherej
isOr adjust how moment is sending your value.
For full date reference, check http://php.net/manual/en/function.date.php