Little prob with Date.strptime


#1

hello
for some reason, the Date.strptime is mixing up my date. pl see here.
the date changs from “6/13/2008” to “2020-06-13”

irb(main):001:0> require ‘date’
=> true
irb(main):006:0> entry=“6/13/2008”
=> “6/13/2008”
irb(main):007:0> Date.strptime(entry,’%m/%d/%y’)
=> #<Date: 4918027/2,0,2299161>
irb(main):008:0> nowdate=Date.strptime(entry,’%m/%d/%y’)
=> #<Date: 4918027/2,0,2299161>
irb(main):009:0> nowdate.to_s
=> “2020-06-13”


#2

On Feb 27, 3:22 pm, Junkone removed_email_address@domain.invalid wrote:

irb(main):008:0> nowdate=Date.strptime(entry,’%m/%d/%y’)
=> #<Date: 4918027/2,0,2299161>
irb(main):009:0> nowdate.to_s
=> “2020-06-13”

you ned %Y, not %y (note the capitalization). im guessing that since
%y means yy, its only taking the first 2 digits of your year (20) and
using that as the year.