How do I take a numeric month, day and year from three separate text inputs and parse a proper value for my DateTime field in the db?
views:
45answers:
1
A:
date = Date.civil(params[:year].to_i, params[:month].to_i, params[:day].to_i)
Isaac Cambron
2010-06-30 03:46:33
It should be params[:year], params[:month], etc. Also, you will have to use .to_i to convert to an integer if using a textfield.
jluebbert
2010-06-30 06:17:15
@jluebbert fixed
Isaac Cambron
2010-06-30 07:27:02