I have a form input code like this:
<%= f.time_select :delivery_time, {:default => 5.hours.from_now, :minute_step => 5, :ampm => true}, {:class=>"input-small"} %>
This is submitting value like: 2013-04-09 23:00:00 UTC
But i want value like : 23:00 as need define condition on time irrespective of date. I tried doing something like:
if (@order.delivery_time.between?('21:00', '00:00'))
@order.total = @order.total + @@mnc
end
But It gives error as delivery_time is nil:class. But when print delivery_time it prints : 2013-04-09 23:00:00 UTC.
Not getting how to get it work. Can anyone help?
You could probably conjure some date values so that you could call
#between?
. It would be simpler and more intention-revealing to extract just the part of the date you need to compare.