Reputation: 6684
I am pretty familiar with strptime
in Rails, but I cannot get this date to format. The date is coming from a long .csv file so it would be a pain to pre-format the dates differently.
date = "2/9/17"
Date.strptime(date, "%-m/%-d/%y")
ArgumentError: invalid date
Upvotes: 0
Views: 28
Reputation: 4435
From the strptime
documentation:
strptime does not support specification of flags and width unlike strftime
So you need a slightly simplified pattern:
date = "2/9/17"
Date.strptime(date, "%m/%d/%y")
# => #<Date: 2017-02-09 ((2457794j,0s,0n),+0s,2299161j)>
Upvotes: 2