Ruby on Rails - passing DateTime as parameter in URL

6.5k views Asked by At

My URL has start parameter as 2015-06-11T11:34+01:00

URL: /admin?start=2015-06-11T11:34+01:00

start_date = params[:start]

When I try to display start_date, I receive 2015-06-11T11:34 01:00 which has + missing. start_date.to_time displays 2015-06-11 11:34:00 UTC. This means it doesn't matter what I send after + i.e., +01:00 or +05:00.

In my ruby console I correctly receive start_date as 2015-06-11 10:24:00 UTC

Please let me know how to retrieve the value of start parameter without the +01:00 getting ignored.

1

There are 1 answers

0
webster On

Get the param value as a string:

start_date = params[:start].to_s