开发者

In Rails, how to display date like NOV 22, '09?

开发者_运维知识库

In Rails, how to display date like NOV 22, '09?

And time like: 5:10 PM


Check out the section 3.2, "Adding Date and Time Formats", in th Internationalization Rails Guide. You'll declare the format in a locales file using (I believe):

# config/locales/custom.yml
custom:
  time:
    formats:
      short: "%b %d, '%y"

and call it in your view with:

<p><%= l Time.now, :format => :short %></p>


Date.today.strftime "%b %d, '%y"
Time.now.strftime "%I:%M%p"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜