开发者

Regular Expression DateTime Javascript

I need an expression which matches,DateTime format (DD/MM/YYYY),i've already found it.

However,it only works to (1/6/2009) or (1/5/2010),it doenst support (01/06/2009) or (01/05/2010).

How can i check if a string is a dateTime in Jav开发者_StackOverflowascript?


You can check this nifty library : Date.js


Try this (which I found here):

(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d

In order to make this match dates without leading zeros on the month and the day you will need to change it up a bit:

(0?[1-9]|1[012])[- /.](0?[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d


How about using a datejs library? It has no problem with those patterns.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜