Date.strptime
require 'date'
american_date = '%m/%d/%y'
puts Date.strptime('2/9/07', american_date).to_s # => "2007-02-09"
puts Date.strptime('2/9/68', american_date).to_s # => "2068-02-09"
puts Date.strptime('2/9/69', american_date).to_s # => "1969-02-09"
Related examples in the same category