Not*_*ere 2 ruby-on-rails helpers
是否有与time_ago_in_words相对的rails helper?我似乎无法找到相反的情况......我可以在7天后将其转换为"大约1周".
我可以让它为过去工作:
<%= time_ago_in_words( milestone.due_date) %>
Run Code Online (Sandbox Code Playgroud)
但这对未来不起作用:
<%= time_ahead_in_words(milestone.due_date) %>
Run Code Online (Sandbox Code Playgroud)
难倒.
你可以distance_of_time_in_words(from_time, to_time = 0, options = {})改用.
所以你可以像这样设置它:
<%= distance_of_time_in_words(Time.now, milestone.due_date) %>
| 归档时间: |
|
| 查看次数: |
1060 次 |
| 最近记录: |