我正在使用rails 3 app。并且我无法将我的日期时间值从我的日期时间选择器保存到sql server 2005中的数据库。我一直收到无效的日期。有什么建议吗?
我在我的模型中有这个:
scope :available, lambda {
|checkin, checkout| {
:select => 'amenities.*',
:order => 'id',
:conditions => ["
amenities.id NOT IN
(
SELECT aa.id from amenities aa, amenity_list al WHERE
aa.id = al.amenities_id AND
(
(? BETWEEN al.checkin AND al.checkout) OR
(? BETWEEN al.checkin AND al.checkout)
)
)",
checkin, checkout
]
}
}
这是我的控制器:
def step2
@cart = current_cart
checkin = params[:checkin]
checkout = params[:checkout]
@amenities = Amenity.available(checkin, checkout)
session[:checkin] = checkin
session[:checkout] = checkout
end
的application.js
$(function() {
var dates = $( "#checkin, #checkout" ).datetimepicker({
dateFormat: 'mm/dd/yyyy hh:MM:ss TT',
buttonImageOnly: true,
buttonImage: 'images/icons/cal.png',
showOn: 'button',
showAnim: 'blind',
defaultDate: "+1w",
changeMonth: false,
numberOfMonths: 2,
minDate: new Date(),
onSelect: function( selectedDate ) {
var option = this.id == "checkin" ? "minDate" : "maxDate",
instance = $( this ).data( "datetimepicker" ),
date = $.datetimepicker.parseDate(
instance.settings.dateFormat ||
$.datetimepicker._defaults.dateFormat,
selectedDate, instance.settings );
dates.not( this ).datetimepicker( "option", option, date );
}
});
});
答案 0 :(得分:0)
您是否尝试过Date.parse(签入)?