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.
我如何在下面解析这些字符串:
01 02 03
这样我就可以使用 strftime('%I %p') 将其变为:
01 AM 02 AM 03 AM
require 'date' DateTime.strptime('01', '%H').strftime('%0l %p') => "01 AM"
也就是说,如果字符串已经是“01”,为什么不在上面贴上 AM 或 PM?只能to_i用来确定是在中午之前/之后。
to_i