I am faced with an issue in Ruby on Rails. I am looking to convert a string of format Tue, 10 Aug 2010 01:20:19 -0400 (EDT) to a date object.
Is there anyway i could do this.
Here is what I’ve looked and tried at the following with no luck:
Date.strptime(updated,"%a, %d %m %Y %H:%M:%S %Z")- Chronic Parser
- Ruby: convert string to date
- Parsing date from text using Ruby
Please help me out with this.
What is wrong with
Date.parsemethod?It seems to work.
The only problem here is time zone. If you want date in UTC time zone, then it is better to use
Timeobject, suppose we have string:I couldn’t find simpler method to convert
TimetoDate.