0
我有一個表單輸入這樣的代碼:時間格式提交
<%= f.time_select :delivery_time, {:default => 5.hours.from_now, :minute_step => 5, :ampm => true}, {:class=>"input-small"} %>
這是提交的值,如:2013年4月9日23:00:00 UTC
但是我要像值: 23:00,因爲需要按時定義條件,而不考慮日期。我試着做類似:
if (@order.delivery_time.between?('21:00', '00:00'))
@order.total = @order.total + @@mnc
end
但它給錯誤,因爲delivery_time是零:class。但是,當打印delivery_time時,它會打印:2013-04-09 23:00:00 UTC。
沒有得到如何得到它的工作。誰能幫忙?
[滑軌:如果時間範圍條件]的可能重複(http://stackoverflow.com/questions/15906657/rails-if-condition-for-time-range) – 2013-04-09 19:03:17
@DaveNewton u能告訴溶液問題? – user2206724 2013-04-09 19:08:01
[傳遞一些東西到''它可以實際使用?](http://apidock.com/rails/ActiveSupport/TimeWithZone/between%3F)我不知道爲什麼你的'delivery_time'是零,我有些懷疑這是因爲你可以打印它(你說)。這可能是你如何構建對象,我不知道。 – 2013-04-09 19:09:44