开发者

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

开发者 https://www.devze.com 2023-01-28 15:57 出处:网络
开发者_运维知识库In Rails, how to display date like NOV 22, \'09? And time like:5:10 PMCheck out the section 3.2, \"Adding Date and Time Formats\", in th Internationalization Rails Guide. You\'ll dec
开发者_运维知识库

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

精彩评论

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