我有以下情况。用户从rails的日期和时间选择框输入日期和时间,在控制器中,方法创建,我有以下参数:
"event"=>
{"title"=>"tet",
"start_date(1i)"=>"2013",
"start_date(2i)"=>"4",
"start_date(3i)"=>"26",
"end_date(1i)"=>"2013",
"end_date(2i)"=>"4",
"end_date(3i)"=>"31",
"start_time(1i)"=>"2013",
"start_time(2i)"=>"4",
"start_time(3i)"=>"26",
"start_time(4i)"=>"10",
"start_time(5i)"=>"05",
"end_time(1i)"=>"2013",
"end_time(2i)"=>"4",
"end_time(3i)"=>"26",
"end_time(4i)"=>"10",
"end_time(5i)"=>"05"}
如果我这样做
@event = Event.new(params[:event])
输出
=> #<Event id: nil, start_date: "2013-04-26", title: "tet", created_at: nil, updated_at: nil, owner_id: 0, owner_type: "", archived: false, end_date: "2013-05-01", start_time: "2013-04-26 10:05:00", end_time: "2013-04-26 10:05:00">
end_date与params
中的end_date不同Time.zone
返回
=&GT; (格林尼治标准时间+02:00)耶路撒冷
为什么会这样?
答案 0 :(得分:1)
没有4月31日,所以它可能包含在4月30日(5月1日)之后的第二天