I am wondering if it's possible to get amount of months in rails from response.
If my data contains published.at: '2020-12-31 08:00:00 UTC'
.
How can I render in my html Published: 3 months ago
instead of displaying the entire date?
Now I display it as <%= item.published_at %>
CodePudding user response:
You can use time_ago_in_words
Published <%= time_ago_in_words(item.published_at) %> ago