Laravel时间验证(小时:秒)

Trying to validate an valid 24 hour time.

Request dump,

#parameters: array:6 [▼
  "_token" => "mP2b6fmvlQG6SMgMwz9VI9kZEXtjXqp7hXUjdWdZ"
  "email" => null
  "ageLimit" => null
  "timeFrom" => "0:00"
  "timeTo" => "0:00"
  "alowed_days" => array:7 [▶]
]

Controller validation

    $validation = $request = $request->validate([
        'email' => 'email|required',
        'ageLimit' => 'required|numeric',
        'timeFrom' => 'date_format:H:i',
        'timeTo' => 'date_format:H:i',
    )];

This is failing for some reason? I'm getting "The time from does not match the format H:i."

What am I not understanding?

From here: http://php.net/manual/en/function.date.php

G 24-hour format of an hour without leading zeros 0 through 23
...
H 24-hour format of an hour with leading zeros 00 through 23

The hour values in 0:00 don't have leading zeroes, so H isn't going to match. date_format:G:i should work.

From the docs:

H 24-hour format of an hour with leading zeros

i Minutes with leading zeros

G 24-hour format of an hour without leading zeros

Meaning that you should change "timeFrom" => "0:00" to "timeFrom" => "00:00" or use G instead of H.