我有一个这样的表单输入代码:
<%= f.time_select :delivery_time, {:default => 5.hours.from_now, :minute_step => 5, :ampm => true}, {:class=>"input-small"} %>
这是提交值,如:2013-04-09 23:00:00 UTC
但我想要像:23:00 这样的值,因为无论日期如何,都需要按时间定义条件。我尝试做类似的事情:
if (@order.delivery_time.between?('21:00', '00:00'))
@order.total = @order.total + @@mnc
end
但是它给出了错误,因为delivery_time 是nil:class。但是当打印 delivery_time 它打印:2013-04-09 23:00:00 UTC。
不知道如何让它工作。任何人都可以帮忙吗?