【发布时间】:2015-09-26 18:43:58
【问题描述】:
在 IRB 中,如果我运行以下命令:
require 'date'
Date.today
我得到以下输出:
=> #<Date: 2015-09-26 ((2457292j,0s,0n),+0s,2299161j)>
但在 Rails 控制台中,如果我运行 Date.today,我会得到:
=> Sat, 26 Sep 2015
我查看了 Rails 的 Date class,但找不到 Rails 的 Date.today 显示输出的方式与 Ruby 的输出不同。
谁能告诉,在 Rails 中,Date.today 或 Date.tomorrow 如何格式化日期以很好地显示?
【问题讨论】:
标签: ruby-on-rails ruby date activesupport