I have a date in the format 05/22/2011 13:10 Eastern Time (US & Canada)
How can I convert that into a date object? This is what I used to parse the date from sting but I’m getting invalid date error.
str = "05/22/2011 13:10 Eastern Time (US & Canada)"
Date.strptime(str, "%d/%m/%Y %H:%M:%S %Z")
Your sting:
05/22/2011 13:10 Eastern Time (US & Canada).Here is a number of mistakes in your pattern:
Also your string includes Date and Time as well, so you’d better to use
DateTimeclass instead ofDateclass:or
To work with datetime you should require it first: