我找到了 strftime
方法的格式指令列表 http://ruby-doc.org/core-2.3.0/Time.html#method-i-strftime
有多种选项可以格式化时间,例如工作日、月中的某一天......但我对格式化时间感兴趣
Time.parse("2016-02-30T12:24").strftime("%XXX, at %H:%M")
# => tomorrow at 12:24
这里%XXX
应该是“今天”、“昨天”、“明天”、“2天内”或“3天内”。
Is it possible to extend the directives of
strftime
so that I can use my own placeholder?
最佳答案
我认为以下 distance_of_time_in_words 助手会有帮助。
关于ruby-on-rails - 扩展 strftime 指令以格式化时间,例如 "tomorrow at 14:00",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35745251/