Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
61
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

@hisa0507

created_atなどに日本語曜日入り日付フォーマットを1行で書く

Qiitaの記事に、これ(http://qiita.com/items/20853d5fce6677d0f346)
で日付を日本語にできるとあるが、これだと現在時刻ばかりなので、
忘れないために便乗して補足しておく。

Time.now.strftime("%m/%d(#{%w(日 月 火 水 木 金 土)[Time.now.wday]})")

例えば、Postモデルのcreated_atを日本語化したいときは、
<% @posts.each do |post| %>
post.created_at.strftime("%Y/%m/%d(#{%w(日 月 火 水 木 金 土)[post.created_at.wday]})")
<% end %>

この1行でおk。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
61
Help us understand the problem. What are the problem?