Possible Duplicate:
Safari JS cannot parse YYYY-MM-DD date format?
I have a simple function to calculate the amount of days between to dates.
function checkDias(){
str1 = $('#salida').val();
str2 = $('#regreso').val();
difference = Math.floor(( Date.parse(str2) - Date.parse(str1) ) / 86400000);
if (diferencia > 0) { } else {
console.log(difference); console.log(str1); console.log(str2);
// alert the user....
}
}
I do this to check that the 2nd date is after the first one. In Firefox this works ok but in Webkit (Safari or Chrome) it doesn't. str1 and str2 log into the console just fine but the difference var in Webkit return NaN and in FF it returns the int value.
Any idea why this might be? I'm using a jQuery UI date widget to get and YYYY-MM-DD format but I don't think this has to do anything with it.
Thanks!