Search code examples
laravellaravel-5laravel-5.4laravel-validation

Validate datetime-local input


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?


Solution

  • 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.