如何将 Rails 时间戳格式化为更易于阅读的格式?如果我只是像这样在我的 View 中打印出 created_at
或 updated_at
:
<% @created = scenario.created_at %>
然后我会得到:
2009-03-27 23:53:38 UTC
最佳答案
strftime
(来自 Ruby 的时代)和 to_formatted_s
(来自 Rails 的 ActiveSupport)函数应该能够处理您所有的时间格式化需求。
关于ruby-on-rails - 格式化时间戳,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/693823/