有以下参数哈希:{"start_time(5i)":"00","start_time(4i)":"06","start_time(3i)":"17","start_time(2i)":"1","start_time(1i)":"2014"}
正如您所看到的,这些是时间的一部分,我需要从中创建一个新的Time对象。我该怎么做?提前致谢。
答案 0 :(得分:0)
datetime = DateTime.strptime("#{params['start_time']['(1i)']}-#{params['start_time']['(2i)']}-#{params['start_time']['(3i)']}T#{params['start_time']['(4i)']}:#{params['start_time']['(5i)']}", '%Y-%m-%dT%H:%M')