Date.strptime with format '%m/%d/%Y' : strptime « Date « Ruby






Date.strptime with format '%m/%d/%Y'


require 'date'
four_digit_year_date = '%m/%d/%Y'
puts Date.strptime('2/9/2007', four_digit_year_date).to_s   # => "2007-02-09"
puts Date.strptime('02/09/1968', four_digit_year_date).to_s # => "1968-02-09"
puts Date.strptime('2/9/69', four_digit_year_date).to_s     # => "0069-02-09"

 








Related examples in the same category

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