G0574's Archiver
G0574
»
RubyOnRails
» rails 内置的时间格式化
弯月圆刀
发表于 2008-8-20 18:20
rails 内置的时间格式化
其实用strftime即可,但是有内置的类型,省去打字的麻烦。
DATE_FORMATS = {
:db => "%Y-%m-%d %H:%M:%S",
:short => "%d %b %H:%M",
:long => "%B %d, %Y %H:%M",
:rfc822 => "%a, %d %b %Y %H:%M:%S %z"
}
所以 Time.now.to_s(:db)即可。
页:
[1]
Powered by
Discuz! Archiver
6.1.0 © 2001-2007
Comsenz Inc.