I have params[:month,:day,:year]
and I need to convert them into a DateTime
that I can place in a hidden input.
What's the best way to do this in Rails 3?
You can do
DateTime.new(params[:year], params[:month], params[:day])
Use DateTime.civil
:
require 'date'
date = DateTime.civil( *params.values_at( :year, :month, :day ) )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With