While getting date in rails we do have a requirement where we need to show suffix attached to date like 2nd,3rd etc. There is no direct rails date function to get the same so in order to get date in the following format
Thu, Nov 5th 2015
We can do the following by twisting strftime function a bit like
starts_at_date.try(:strftime,"%a, %b #{starts_at_date.try(:day).try(:ordinalize)} %Y")
Where starts_at_date is the date object from which we are trying to show the date in particular format. Thing to note here is #{starts_at_date.try(:day).try(:ordinalize)} which help you display 2nd , 3rd etc.
0 Comment(s)