I'm using html5 datetime-local type
<input type="datetime-local" value="" name="start_date1"/>
it sends this to the controller: 2015-04-03T00:00
is it possible to convert it to this: 2015-04-03 00:00:00 +0100
it sends this to the controller: 2015-04-03T00:00 is it" /> it sends this to the controller: 2015-04-03T00:00 is it" /> it sends this to the controller: 2015-04-03T00:00 is it"/>
I'm using html5 datetime-local type
<input type="datetime-local" value="" name="start_date1"/>
it sends this to the controller: 2015-04-03T00:00
is it possible to convert it to this: 2015-04-03 00:00:00 +0100
On
In Rails you should set your app's default time zone in config.time_zone. Then
Time.zone.parse(params[:start_date1])
will default to that time zone.
Time.zone can be overridden in runtime, see http://api.rubyonrails.org/classes/ActiveSupport/TimeZone.html#method-i-parse
You should also have a look at this: http://www.elabs.se/blog/36-working-with-time-zones-in-ruby-on-rails
You can try changing
params[start_date1]to the datetime:Here:
Your params value "2015-04-03T00:00" is parsed with '%Y-%m-%dT%R' because, %Y is 2015, %m is 04, %d is 03, "T" tells that time is in 24 hours format. So, we'd just put it as is, and use %R to parse "hours:minutes".
You can read more about
DateTimeformat directives here.