0

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?

0

3 Answers 3

2

You can check this nifty library : Date.js

Sign up to request clarification or add additional context in comments.

Comments

1

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

1 Comment

What about the other centuries? And the 31th of february?
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.