Home > Mobile >  Laravel date_format validation not working
Laravel date_format validation not working

Time:11-29

here is my code:

public function rules()
{
    return [
      'clock_time_from' => 'required|date_format:H:i',
      'clock_time_to'   => 'required|date_format:H:i|after:clock_time_from',
    ];
}

public function messages()
{
    return [
        'clock_time_from.required' => 'Time from required',
        'clock_time_from.date_format' => 'Time From- Please write time correctly',

        'clock_time_to.required'   => 'Time to required',
        'clock_time_to.date_format' => 'Time To- Please write time correctly',
    ];
}

when i put this time in input field like: from: 9:00 to: 13:00

its not working and return me the validation message: 'Time From- Please write time correctly',

so what did i wrong here?

CodePudding user response:

H format is with leading zeros, try with 09:00

  • Related