tags:

views:

45

answers:

3

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 Javascript?

A: 

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

Andrew Hare
What about the other centuries? And the 31th of february?
Alsciende
no,man.thats not quite.it doenst work.Same error.
+2  A: 

You can check this nifty library : Date.js

Alsciende
A: 

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

S.Mark