How to convert a string to datetime in ruby -
this question has answer here:
in ruby string "tuesday, january 19, 2016 8:00 pm" options have converting date/time format recognized ruby?
edit: similar questions ask converting mm/dd/yyyy format, question different format appears answer same. understand why may appear duplicate not.
you can use datetime.strptime
.
example:
2.1.2-perf :029 > datetime.strptime("tuesday, january 19, 2016 8:00 pm", "%a, %b %d, %y %i:%m %p") => #<datetime: 2016-01-19t20:00:00+00:00 ((2457407j,72000s,0n),+0s,2299161j)>
Comments
Post a Comment