显示日期时间,如1小时前,5小时前,3天前,[重复]

时间:2022-08-25 17:47:56

Possible Duplicate:
How do you do relative time in Rails?

可能重复:如何在Rails中做相对时间?

I want to display the datetime like this:

我想这样显示datetime:

30 seconds ago
1 hour ago
9 hours ago
2 days ago
1 year ago
..

Is this built in or should I write my own function to do this?

这是内置的还是我应该自己写函数来做这个?

1 个解决方案

#1


7  

http://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html#method-i-distance_of_time_in_words

http://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html method-i-distance_of_time_in_words

#1


7  

http://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html#method-i-distance_of_time_in_words

http://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html method-i-distance_of_time_in_words