我想知道是否有可能從回應中獲得rails中的月份數量。
如果我的資料包含published.at: '2020-12-31 08:00:00 UTC'。
我怎樣才能在我的HTML中呈現Published: 3 months ago而不是顯示整個日期?
現在我把它顯示為<%= item.published_at %>
uj5u.com熱心網友回復:
你可以使用time_ago_in_words
Published <%= time_ago_in_words(item.published_at) %> ago
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/313824.html
標籤:
下一篇:如何根據陣列的回應值進行回圈排序
