I have a string: \"31-02-2010\" and want to check whether or not it is a valid date. What is the best way to do it?
\"31-02-2010\"
I need a method which which returns
Similar to the solution by @ironsand, I prefer to create an overridden instance method on String:
String
class String def valid_datetime? to_datetime true rescue ArgumentError false end end