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

Popular posts from this blog

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -