0

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?

2

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

2 Comments

How to write validation if written without leading zero?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.