2

My date format input is like -Mon Nov 23 2015 10:24:04 GMT+0530 (India Standard Time)

I want validate above date with regularExpression like if the user given input formatt is Mon Nov 23+-}\ 2015 10:24:04 abcd GMT+0530 (India Standard Time) then validate that date with RegEx

Mehul Tandale
  • 331
  • 1
  • 5
  • 17
  • I'm not good with regex but I guess creating `Date` object should also help. – Rajesh Nov 23 '15 at 10:47
  • 1
    is it necessary to go with RE ? If not that this may help you : http://stackoverflow.com/questions/1353684/detecting-an-invalid-date-date-instance-in-javascript – krish Nov 23 '15 at 10:48
  • Sharing your research helps everyone. Tell us what you've tried and why it didn't meet your needs. This demonstrates that you've taken the time to try to help yourself, it saves us from reiterating obvious answers, and most of all it helps you get a more specific and relevant answer! Also see [how to ask](http://stackoverflow.com/questions/how-to-ask) – Cerbrus Nov 23 '15 at 10:49
  • 1
    You can use valueOf method to validate date. Say var date = new Date("Mon Nov 23+-}\ 2015 10:24:04 abcd GMT+0530 (India Standard Time)"); date.valueOf(); if the date is invalid date.valueOf() should return NaN otherwise it will return the timestamp. – Indrajith Nov 23 '15 at 11:10

0 Answers0