是否有可能在我的HTML檔案中格式化日期?
我從item.starts_at
starts_at: '2018-01-10 07:28:00'。
我想把它顯示為1月10日
uj5u.com熱心網友回復:
<%= item.starts_at.strftime('%b %d'/span>) %>
uj5u.com熱心網友回復:
I18n.l(Date.today, format: :short)就是你要找的東西,Rails包括這些本地化格式,更多細節。https://github.com/rails/rails/blob/b2eb1d1c55a59fee1e6c4cba7030d8ceb524267c/activesupport/lib/active_support/locale/en.yml#L3
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/313826.html
標籤:
