我的Ruby程序說我的日期是無效的,當我做到這一點:我在做什麼DateTime.strptime錯誤?
format = "%D/%M/%Y %H:%M:%S:3N"
date = "21/03/2011 16:39:11.642"
DateTime.strptime(time, format)
我自己也嘗試這一個:
format = "%D/%M/%Y %H:%M:%S:3"
我得到的是這樣的:
ArgumentError: invalid date
from /usr/local/lib/ruby/1.9.1/date.rb:1688:in `new_by_frags'
from /usr/local/lib/ruby/1.9.1/date.rb:1713:in `strptime'
from (irb):12
from /usr/local/bin/irb:12:in `<main>'
我發現http://strfti.me/用於建立這些格式字符串真的很棒。 – opsb 2012-08-30 09:55:29
因此'strftime'和'strptime'的格式字符串符號有不同的含義? – 2013-06-13 05:42:36
謝謝邁克爾。這真的幫了我 – 2013-11-02 17:50:52