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.
$ irb 1.9.3-p429 :001 > require 'date' => true 1.9.3-p429 :002 > Date.strptime('04/08/13' , '%m/%d/%Y').strftime('%Y-%m-%d') => "0013-04-08"
出于某种原因,今年,而不是2013它显示0013?:)
你的格式有小错误,应该是%m/%d/%y
%m/%d/%y
Date.strptime('04/08/13', '%m/%d/%y').strftime('%Y-%m-%d') => "2013-04-08"