According to MDN, I should use datetime-local
type for a date and a time input:
<input type="datetime-local">
I can validate a date in laravel with this code (in a controller):
$this->validate($request, ['my_date' => 'required|date']);
But is there a way to validate a datetime-local
?
In your example:
$this->validate($request, ['my_date' => 'date_format:Y-m-d\TH:i']);
You can use date_format:format
or date
to validate. All date validation is performed by php strtotime
The best way to know for sure is to test this. Create your rules
function in the controller and test, that way you know for sure for your laravel version and your php version as you don't mention that information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With