First of all, it doesn't seem that the DateTime format variables are documented anywhere so a +1 to anyone who can show this to me in rubydocs. Second of all, when looking at the Date.strftime
function code, I don't see anything that can let me do something like:
首先,看起来DateTime格式变量似乎没有在任何地方记录,因此对于任何可以在rubydocs中向我显示的人来说都是+1。第二,在查看Date.strftime函数代码时,我没有看到任何可以让我做类似的事情:
Thursday, September 9th 2010
2010年9月9日星期四
Does anyone know if this is possible?
有谁知道这是否可能?
2 个解决方案
#1
25
You might want to take a look here.
你可能想看看这里。
To summarize
time = DateTime.now
time.strftime("%A, %B #{time.day.ordinalize} %Y")
Note that you are running in plain Ruby (2.0) you'll need to call:
请注意,您运行的是纯Ruby(2.0),您需要调用:
require 'active_support/core_ext/integer/inflections'
#2
-1
You can found all means %xx in Time documentation
您可以在Time文档中找到所有均值%xx
http://ruby-doc.org/core/classes/Time.html#M000298
So you just need made
所以你只需要制作
date.strftime('%A, %B %d %Y')
#1
25
You might want to take a look here.
你可能想看看这里。
To summarize
time = DateTime.now
time.strftime("%A, %B #{time.day.ordinalize} %Y")
Note that you are running in plain Ruby (2.0) you'll need to call:
请注意,您运行的是纯Ruby(2.0),您需要调用:
require 'active_support/core_ext/integer/inflections'
#2
-1
You can found all means %xx in Time documentation
您可以在Time文档中找到所有均值%xx
http://ruby-doc.org/core/classes/Time.html#M000298
So you just need made
所以你只需要制作
date.strftime('%A, %B %d %Y')