var date1 = new Date(2014, 1, 1);
var date2 = new Date(2014, 3, 21);
var times=date2.getTime() - date1.getTime();
var days = parseInt(times / (1000 * 60 * 60 * 24));
alert(days); //相差天数
var date1 = new Date(2014, 1, 1); var date2 = new Date(2014, 3, 21); var times=date2.getTime() - date1.getTime(); var days = parseInt(times / (1000 * 60 * 60 * 2