我想知道是否有可能從回應中獲得幾個月的軌道。如果我的資料包含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/qukuanlian/416227.html
標籤:
下一篇:格式化html.erb中的日期
