0

is there a good regex expression that would be able to compare two dates like 3/27/2010 to 3/8/2010 to tell if the first date is greater then the second date?

I'd like to compare using javascript

1
  • why don't you convert the string to a date object and then compare the two dates? Commented Mar 8, 2010 at 21:04

2 Answers 2

3
if (new Date("3/27/2010") < new Date("3/8/2010")) {
   alert("something's wrong.");
}
Sign up to request clarification or add additional context in comments.

Comments

0

It is almost impossible, and completely insane, to do this with a regular expression.

Instead, use Javascript's Date object:

if (new Date(str1) > new Date(str2))

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.