Parse any date time string into a date object

Public, Ruby General


Created: Aug 13, 2020     Updated: Aug 13, 2020

Use Ruby's Date #strptime method to take any date or date time object that has been created with the #strftime method, and parse it into an instance of Date.

Here are some examples:

> Date.strptime('5/22/74', "%m/%d/%y")
=> Wed, 22 May 1974

)> Date.strptime('2001-02-03', '%Y-%m-%d')
=> Sat, 03 Feb 2001