Laravel Date Validation

Laravel Date Validation
----------------------------------------------

Laravel provide some handful method for date validation.

Date validation Rules
Here is the list of validation rules

  • date
  • date_format
  • after:date
  • after_or_equal:date
  • before:date
  • before_or_equal:date

after:date

The field under validation must be a value after a given date. The dates will be passed into the strtotime PHP function:

$rules = ['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:
$rules = ['finish_date' => 'required|date|after:start_date'];

before:date

$rules = ['start_date' => 'required|date|before:tomorrow'];

// with date_format
$rules = ['start_date' => 'date_format:d/m/Y'];

 

Categories: PHP Tags: #Laravel,

Newsletter Subcribe

Receive updates and latest news direct from our team. Simply enter your email.