0

I have an issue where I am being passed DOB in a variable from another source in the format of YYYY/MM/DD but in the application the customer is then asked to input DOB in the following format YY/MM/DD.

What function in Javascript or ECMA can I use to match these dates?

I need to match the DOB or not match so I can move to the next state. Its bad planning from my client but I need to find a way around it.

I am not a Javascript or ECMA person, so I am limited in what I can do. I am not sure I can do anything with it at all with the difference between the 2 date formats.

  • I am not sure this is a duplicate of the above. I am not just converting I am trying to match. So throughout, I have a varcust_DOB being passed with "YYYY-MM-DD', I am then asking the customer in the application to enter their DOB in the format of 'DD-MM-YY'. I need logic in my application to say if varDOBinput "DD-MM-YY' = 'varcust_DOB'(format YYYY-MM-DD) – Russell Heaney May 23 '18 at 12:47
  • this is a valid question if you are a newbie to Javascript. Sorry, not enough space to add comments. One option is manipulate and compare as strings. // if the date formats are in DD-MM-YY and YYYY-MM-DD //swap around //get DD, MM, YY var varDOBinput='11-01-90'; //11th Jan 1990 DD-MM-YY var varcust_DOB='1990-01-11'; //11th Jan 1990 YYYY-MM-DD var new_varcust_DOB=varcust_DOB.substr(8,2)+'-'+varcust_DOB.substr(5,2)+'-'+varcust_DOB.substr(2,2); if (varDOBinput === new_varcust_DOB) console.log('matching DOB') else console.log('non matching DOB'); – JohnC May 23 '18 at 17:24
  • https://codepen.io/newschapmj1/pen/Pevoqq?editors=1111 for better view – JohnC May 23 '18 at 17:37

0 Answers0