Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
I am trying to convert a string like "6 months ago" and "3 days ago" to a date/datetime.
Any ideas?
Thanks in advance!
The Chronic gem provides such a feature. (Github, RubyGems)
It can parse rather complex statements. For example
can all be parsed.
Add a comment
In rails, it can be done easily without other gems:
eval("3 days ago".gsub(" ",".")) # => Mon, 05 Aug 2013 13:31:06 UTC +00:00
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.