문제

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:

Thursday, September 9th 2010

Does anyone know if this is possible?

도움이 되었습니까?

해결책

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:

require 'active_support/core_ext/integer/inflections'

다른 팁

You can found all means %xx in Time documentation

http://ruby-doc.org/core/classes/Time.html#M000298

So you just need made

date.strftime('%A, %B %d %Y')
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top