My problem is that I receive a String element from my form, which can be of these two formats:
fecha = "010117";
or
fecha = "01012017";
And I need to format them to a date format valid as "01/01/2017"
, I've tried to do it in several ways, including this one:
var newfecha = new Date( fecha.replace( /(\d{2})-(\d{2})-(\d{4})/, "$2/$1/$3") );
But do not do it correctly, could someone give me any suggestions?