LoginSignup
8
10

More than 5 years have passed since last update.

Railsで「何日前」と表記

Last updated at Posted at 2014-09-03

メモ
「約〜時間前」とか表示したいとき

distance_of_time_in_words_to_now(post.created_at)
ja.yml
ja:
  datetime:
    distance_in_words:
      about_x_hours:
        one: 約1時間
        other: 約%{count}時間
      about_x_months:
        one: 約1ヶ月
        other: 約%{count}ヶ月
      about_x_years:
        one: 約1年
        other: 約%{count}年
      almost_x_years:
        one: 1年弱
        other: ! '%{count}年弱'
      half_a_minute: 30秒前後
      less_than_x_minutes:
        one: 1分以内
        other: ! '%{count}分以内'
      less_than_x_seconds:
        one: 1秒以内
        other: ! '%{count}秒以内'
      over_x_years:
        one: 1年以上
        other: ! '%{count}年以上'
      x_days:
        one: 1日
        other: ! '%{count}日'
      x_minutes:
        one: 1分
        other: ! '%{count}分'
      x_months:
        one: 1ヶ月
        other: ! '%{count}ヶ月'
      x_seconds:
        one: 1秒
        other: ! '%{count}秒'
8
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
8
10