3
2

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.

Laravelで曜日表記を日本語にする

Last updated at Posted at 2019-02-07

2018年8月20日(木) って表示したいのに 2018年8月20日(Thu) と表示されて手元のThinkPadを窓から投げそうになったことはありませんか?

こういう場合は format() ではなく formatLocalized() を使います。

Carbon::now()->formatLocalized('%Y年%m月%d日(%a)');

これで正しく表示されてめでたしめでたしですね!

どうしても英字表記になってしまう場合は

localeを日本にする

PHPのロケーション設定を日本にします。
もし、稼働中の環境にmbstring拡張モジュールが入っていない場合は入れましょう。日本語を扱う上でmbstringは必須のようなものです。

setlocale(LC_ALL, 'ja_JP.UTF-8')

OSに日本語ロケールを入れる

これを知らなかったのでかなりの時間悩まされました。Homesteadの場合は vagrant ssh でSSHに入って次の記事にあるコマンドを叩けばOKです。

3
2
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
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?