13
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Laravel5.2 日付Validationのフォーマット

Last updated at Posted at 2016-08-12

Laravel5.2 日付Validationのフォーマットについて

・YYYY/MM/DDを設定したい
・HH:MMも設定したい

Validation設定方法

YYYY/MM/DDおよびHH:MMをValidationに設定したい場合、フォーマットの指定は以下のコードになる。

controller.php
    $validator = Validator::make($request->all(), [
        'date' => 'date_format:Y/m/d',   /* 「y/m/d」ではない。*/
        'time' => 'date_format:H:i',     /* 「H:M」ではない*/
    ]);

参考記事

Laravel 5.1 date_format validation allow two formats

13
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?