ruby on rails - YML Date formatting according to user profile settings -
each user of our application can have different format date. can use date::date_formats[:default] = "%m/%d/%y"
in application controller changing default date formatting.
but want change date formats in en.yml to:
date: formats: default: "%y/%m/%d" short: "%b %d" long: "%b %d, %y"
how can change default, short , long date formates in yml file on fly can use date::date_formats[:default] = "%m/%d/%y"
.
note: in view use <%= l time.now.to_date, :format=>:short%>
thanks.
you can use in application controller different data format. write in application controller. time::date_formats.merge!(:data_format => "%d-%b-%y") time::date_formats.merge!(:data_format_month => "%m-%d-%y")
and in view or helper call data_format or data_format_month. example created_on.to_s(:data_format) displaying d-b-y format update_on.to_s(:data_format_month ) displaying m-d-y format
Comments
Post a Comment