0

I'd like to display my date with an ordinal date e.g. 9th Feb 2014. I don't seem to be able to get my syntax right though. Here's what I have that works, but not sure how to correctly ordinalize the dates. At the moment it says 9 Feb 2014

= "Shared #{review.created_at.strftime("%d %b %Y")}"

2 Answers 2

1
Shared #{review.created_at.strftime("#{review.created_at.day.ordinalize}" " %b %Y")}
3
  • Awesome, thanks. Complete code that words is "Shared #{review.created_at.strftime("#{Time.new.day.ordinalize}" " %b %Y")}"
    – tessad
    Feb 9, 2014 at 8:33
  • @tessad use review.created_at.day.ordinalize instead of Time.new.day.ordinalize
    – Raj
    Feb 9, 2014 at 8:46
  • Time.new.day.ordinalize will always return today's ordinalized date not the review created date
    – Raj
    Feb 12, 2014 at 7:51
0

Time.new.strftime("#{Time.new.day.ordinalize} %b %Y")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.