检查字符串是否为日期值
问题描述:
检查某个值是否为有效日期,允许使用任何已知日期格式的简便方法是什么。
What is an easy way to check if a value is a valid date, any known date format allowed.
例如我的值 10-11-2009
, 10/11 / 2009
, 2009-11-10T07:00:00 + 0000
应该全部被识别为日期值,值 200
, 10
, 350
,不应将其识别为日期值。如果可能的话,最简单的检查方法是什么?因为时间戳也是允许的。
For example I have the values 10-11-2009
, 10/11/2009
, 2009-11-10T07:00:00+0000
which should all be recognized as date values, and the values 200
, 10
, 350
, which should not be recognized as a date value. What is the simplest way to check this, if this is even possible? Because timestamps would also be allowed.