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
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
You probably should take a look to this bit of the documentations. A custom rule sounds like your way to go.
Probably this code would work in your controller. However it won't validate times from different days (eg 9pm - 3am next day).
time_start
andtime_end
in this case should be provided asHH:mm
but you can change it easily.Create DateRequest and then add
Try This code
Use date_format rule validation
From docs
The field under validation must match the format defined according to the date_parse_from_format PHP function.