Given an array of DateTime Strings, I want to just fetch the times e.g. 10:30:00.
So far I come up with this, but it wont give me the right result:
["2011-07-30 10:00:00","2011-07-30 12:00:00"].each{|item| item.match(/\d{2}:\d{2}:\d{2}/)}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If all the strings really are like that then just do some substring mangling:
This will also work if your timestamps include things like
2011-07-30 10:00:00.1123,2011-07-30T10:00:00, or2011-07-30 10:00:00 +0700.If you wanted to be friendlier to the future, then you could do this:
so no one would have to guess what the
11and8were all about.