Reputation: 12347
I have this Example which does not work in IE, but works in all other browsers can you take a look. What is the problem here? Note: This is a continuation of this
Updated : The problem is my example works in chrome but gives NaN in IE 8 and firefox 6.
My Code
var cellvalue="2011-08-18 11:49:01.0 IST";
var firstDate = new Date();
var secondDate = cellvalue.substring(0, cellvalue.length-4);
alert(diffOf2Dates(firstDate,secondDate));
function diffOf2Dates(todaysDate,configDate)
{
/*var udate="2011-08-18 11:49:01.0";
var configDate=new Date(udate);*/
var oneDay = 24*60*60*1000; // hours*minutes*seconds*milliseconds
var firstDate = todaysDate; // Todays date
var secondDate = new Date(configDate);
var diffDays = Math.abs((firstDate.getTime() - secondDate.getTime())/(oneDay));
return Math.ceil(diffDays);
}
Note: My format
2011-08-19 11:49:01.0 IST
Upvotes: 0
Views: 436
Reputation: 15579
the problem is the fomat of the date: ie doesnt support the way other browsers do.. run this: jsfiddle.net/vQnHz/7
it is recommended you use this constructor: var variable = new Date(year, month, day, hours, minutes, seconds, milliseconds2)
Upvotes: 2