Here, In RUBY I need a format of Like this
"February 1st 2011 11.00"
. I tried this one
"Time.now.utc.strftime("%B %d %Y %R")"
But I need to format numerals with suffixes st, nd, rd, th etc. Please suggest something.
If you specifically want "February 1st 2011 11.00" you would need to add your own DATE_FORMATS and call that.
Time::DATE_FORMATS[:custom_ordinal] = lambda { |time| time.strftime("%B #{ActiveSupport::Inflector.ordinalize(time.day)} %Y %H.%M") }
puts Time.now.to_s(:custom_ordinal)
# February 28th 2011 02.12
If all you want is an ordinal date and "February 28th, 2011 02:12" works, then call Time.now.to_s(:long_ordinal)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With