I am trying to parse a string 26/03/2012, in dd/mm/yyyy format to Ruby's Date using Date.strptime, as follows:
#!/usr/bin/ruby
require 'date'
puts 'Ruby Version: ' + RUBY_VERSION
date_str = '26/03/2012'
date = Date.strptime(date_str, "%d/%m/%y")
puts 'Parsed Date: ' + date.to_s
The output is:
Ruby Version: 1.8.7
Parsed Date: 2020-03-26
The year part has become 2020, instead of 2012!