Date validation in Laravel

Laravel provides many convenience ways to validate date

From document let’s take after for example

> The field under validation must be a value after a given date. The dates will be passed into the strtotime PHP function in order to be converted to a valid DateTime instance:

'start_date' => 'required|date|after:tomorrow'

Instead of passing a date string to be evaluated by strtotime, you may specify another field to compare against the date:

'finish_date' => 'required|date|after:start_date'

However, how to validate with a custom format?

Luckily, we have date_format validator

'start_date' => 'required|date_format:Y-m-d H:i:s|after:' . date('Y-m-d H:i:s')

With this format, we can put anything we need there to validate

--

--