Displaying 1 result from an estimated 1 matches for "format_date_time".
2012 Apr 17
6
ActiveRecord with different Date/Time format
...ams map
2. Parse it with user''s preferred datetime format
3. Format datetime to the default format used by ActiveRecord
4. Replace current datetime in params with re-formatted datetime
Here is a snippet of the controller
class ArticlesController < ApplicationController
before_filter :format_date_time, :only => [:create, :update]
...
...
private
def format_date_time
datetime = params[:datetime]
params[:datetime] = DateTime.strptime(datetime,
pref_date_time_format).strftime(''%c'')
end
end
Would anyone please verify if it is right approach or not? Als...