datetime - Change date format in rails 4 -
i have got date format in text_field -> 2014-11-14 20:45:00
i want come in in database in rails 4. how can save easy way in database column type "datetime"?.
i have tried below way seems no working.
params[:task_assign][:task_assign_scheduled_on]=datetime.civil( params[:task_assign][:"task_assign_scheduled_on(1i)"].to_i, params[:task_assign][:"task_assign_scheduled_on(2i)"].to_i, params[:task_assign][:"task_assign_scheduled_on(3i)"].to_i, params[:task_assign][:"task_assign_scheduled_on(4i)"].to_i, params[:task_assign][:"task_assign_scheduled_on(5i)"].to_i)
activerecord automagically converts valid datetime string upon persisting record. format gets saved db dependent on db using , settings. typically, pg save datetime utc datetime string.
if want save datetime in particular format, need either update db settings, or save attribute string.
ruby-on-rails datetime date-formatting
No comments:
Post a Comment