How to convert a string 01/02/1994 to the type 1/2/1994 js

  • Is this view rigidly set? or may be options? - Grundy
  • My date of birth is entered in the form 01.02.1994 I need to find out the age. I do it like msdn.microsoft.com/ru-ru/library/ee532932
  • Well then I'm afraid you initially did not correctly ask the question, asked not at all what is really necessary. but the answer to this question has already been given ... - Mike
  • Possible duplicate question: Conversion of the string to the mind 1994-02-01 - Igor Lavrynenko

3 answers 3

console.log('01.02.1994'.split('.').map(num => +num).join('/')); 

  • one
    Can be .map(Number) - Qwertiy

 console.log("01.02.1994".replace(/^0?(\d+)\.0?(\d+)\.(\d+)$/, '$1/$2/$3')) 

    If the conversation is about the line, then you can apply this option:

     var str = "1.2.1994"; var newStr = str.replace(/\./g, '/'); console.log(newStr); 

    • In the question, more zeros should be removed. And do not delete the answers and write the same. - Qwertiy