Why is ‘time’ being returned as an invalid date?
val = "9/22/2011 4:23 AM"
time = DateTime.parse(val).strftime("%Y-%m-%d %H:%M:%S").to_datetime
#at breakpoint: time = 2011-09-22T04:23:00+00:00 as a DateTime Object
@form_entry.storage_datetime = time # crashes here with invalid date
If it helps, I’m using gem mysql 2.8.1 and Ruby 1.9.2. Thanks
I got an
ArgumentErroron line two; couldn’t create the DateTime object in the first place.Try using
strptimeinstead: