Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有以下字符串作为日期
Thu 17 Jan
我想将其转换为 ruby 日期时间对象(保存在数据库中)。我试过慢性,但没有运气。
有人可以帮我吗,在此先感谢
不需要慢性。简单的日期就可以了。
require 'date' s = 'Thu 17 Jan' Date.parse(s) # => #<Date: 2013-01-17 ((2456310j,0s,0n),+0s,2299161j)>
您还可以使用:
s = 'Thu 17 Jan' date = DateTime.parse(s)