Search code examples
phplaravellaravel-validation

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


Solution

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