Date.strptime : strptime « Date « Ruby






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

1.Date.strptime with format '%d/%m/%y'
2.Date.strptime with format '%m/%d/%Y'
3.Date.strptime with format '%A, %B %d, %Y'