distance_of_time_in_words
Description
distance_of_time_in_words(from_time, to_time = 0, include_seconds = false)Reports the approximate distance in time between two Time objects or integers. For example, if the distance is 47 minutes, it’ll return "about 1 hour". See the source for the complete wording list.
Integers are interpreted as seconds. So, distance_of_time_in_words(50) returns "less than a minute".
Set include_seconds to true if you want more detailed approximations if distance < 1 minute
Examples:
- <%= distance_of_time_in_words(3.days.ago, 2.days.ago) %>
- this results in "24 hours ago"
User Contributed Notes add
- <%= distance_of_time_in_words(3.days.ago, 2.days.ago) %>
- this results in "24 hours ago"
No comments