我在数据库中有一个日期时间列,当我向用户显示它时,我想将其转换为一个简单的日期。
我怎样才能做到这一点?
def shown_date
# to_date does not exist, but is what I am looking for
self.date || self.exif_date_time_original.to_date
end
DateTime#to_date
ActiveSupport 确实存在:
$ irb
>> DateTime.new.to_date
NoMethodError: undefined method 'to_date' for #<DateTime: -1/2,0,2299161>
from (irb):1
>> require 'active_support/core_ext'
=> true
>> DateTime.new.to_date
=> Mon, 01 Jan -4712
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)