不同格式的ROR + Ruby日期

时间:2011-04-15 08:37:39

标签: ruby ruby-on-rails-3 postgresql date

如果我有@today = Thu Apr 21 2011 00:00:00 GMT 0530 (IST),

如何将@today转换为"Thur April 21, 2011"

1 个答案:

答案 0 :(得分:4)

Time.now.strftime("%a %B %d, %Y")
=> "Fri April 15, 2011"

在你的场合:

@today.to_time.strftime("%a %B %d, %Y")
=> "Thu April 21, 2011"