Ruby 如何获取数据库中存储的默认格式的日期

Ruby how to get a date to the default format as it's stored in the db

我的数据库默认存储时间如下:

Object.last.created_at
# => Fri, 03 Jul 2015 23:27:50 UTC +00:00

我查看了 strftime 文档,我可以自己构建它,但似乎必须有一种简单的方法才能将常规 Date 对象获取为该格式?只是想知道是否有...

to_datetime 真的很近,但不是一直到那里。

Date.today.to_datetime # => 2015 年 7 月 4 日星期六 00:00:00 +0000

还有其他想法吗?

试试这个

Time.zone.now
#=> Sat, 04 Jul 2015 20:32:44 UTC +00:00

更新

DateTime.now.in_time_zone
#=> Sat, 04 Jul 2015 20:43:57 UTC +00:00

我真傻……只是

Date.today.in_time_zone
# => Mon, 06 Jul 2015 00:00:00 UTC +00:00