Laravel 8 date_format Validation Example

Share Me
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
Laravel 8 date_format Validation

Hello Dev’s
Today in this tutorial I will show you laravel 8 Date Format Validation. We can easily validate date_format validation rules. By using date_format:format method we can set the preferred date format, and then filed value must match the given format. Now we see how to Laravel 8 date_format Validation work.

So now the field under validation must match as like the given format. Now we should use either date_format when need to validate a field, not both of field. So this validation rule supports all formats supported by PHP’s Date class.

Example

public function store(Request $request)
{
    $request->validate([
        'start_date' => 'date_format:d/m/Y',
        'end_date' => 'date_format:d/m/Y'
    ]);
}

OR

public function store(Request $request)
{
  $request->validate([
      'start_date' => 'date_format:Y-m-d',
      'end_date' => 'date_format:Y-m-d'
  ]);
}

Read Also : Upload image and create thumbnail in codeigniter – example

Thanks for read. I hope it help you. For more you can follow us on facebook

About code chef

My name is Shahriar sagor. I'm a developer. I live in Bangladesh and I love to write tutorials and tips that will help to other Developer's. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by code chef →