snex
2/27/2009 9:47:00 PM
On Feb 27, 3:22 pm, Junkone <junko...@gmail.com> wrote:
> 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"
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.