I am using Ruby On Rails 4 and twitter-bootstrap-rails, to the client wants to dislay dates in this format:
14 September 2013
Well pretty cool, there we go:
var start = $("#project_start_date").datepicker({ format: 'dd MM yyyy', autoclose: true })
However when the date is saved to the database it is saved as "2013-09-14". Well cool, however when I want to edit the page I see the following:
2013-09-14
as the output of the field :( Not good hey.
So how would you output the date in a given format (I probably need @start_date.stftime("%d %B %Y")
.
Just wanted to say, that:
- getter methods didn't do the job:
def start_date() @start_date.stftime("%d %B %Y") end
- before_validation also didn't do:
before_validation :date_validation def date_validation @start_date = self.start_date.strftime("%D %m %Y") @end_date = self.end_date.strftime("%d %m %Y") end
PS I am using Postgres.