To solve this problem I a made function who manage the change from text to date:
My examples works with date as this: Jun/1/2016 to 2016-06-01 you can rebuild the function to make your format works...
The cero's at the left of the numbers are added to match the date type format.
function textoafecha(texto)
{
hasNumber = /\d/;
// Contiene el pedazo del texto que contiene el mes
mestexto = texto.substr(0,3);
// Contiene el pedazo de texto que contiene el primer numero del dia
diatextonumero1 = texto.substr(4,1);
diatextonumero2 = texto.substr(5,1);
// Si el texo contiene un numero...
if (hasNumber.test(diatextonumero2))
{
dia = texto.substr(4,2);
anotexto = texto.substr(7,4);
}
else
{
dia = texto.substr(4,1);
dia = "0"+ dia;
anotexto = texto.substr(6,4);
}
switch (mestexto)
{
case "Jan" : mesnumero = "01";
break;
case "Feb" : mesnumero = "02";
break;
case "Mar" : mesnumero = "03";
break;
case "Apr" : mesnumero = "04";
break;
case "May" : mesnumero = "05";
break;
case "Jun" : mesnumero = "06";
break;
case "Jul" : mesnumero = "07";
break;
case "Aug" : mesnumero = "08";
break;
case "Sep" : mesnumero = "09";
break;
case "Oct" : mesnumero = "10";
break;
case "Nov" : mesnumero = "11";
break;
case "Dec" : mesnumero = "12";
break;
default : break;
}
fechaformateada = anotexto + "-" + mesnumero + "-" + dia;
return fechaformateada;
}
var newVar = new Date(dateVar);
seems to be working for me. Trynew Date("2014-03-05")
in the console – Oeillade