Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to validate time in laravel

I want to validate time in Laravel. Ex:- I want that when user input the time between 8 PM to 10 PM then it will show the validation error. How can I achieve that in Laravel

like image 430
Vikash Avatar asked Sep 13 '16 10:09

Vikash


People also ask

What is bail in laravel validation?

you can easily use bail validation in laravel 6, laravel 7, laravel 8 and laravel 9. If you added more then one validation on your field like required, integer, min and max then if first is fail then other should stop to display error message. right now by default it print other too.


1 Answers

Use date_format rule validation

date_format:H:i 

From docs

date_format:format 

The field under validation must match the format defined according to the date_parse_from_format PHP function.

like image 179
Chathuranga Tennakoon Avatar answered Oct 08 '22 19:10

Chathuranga Tennakoon