JS时间相减得出天数
var date = new Date(); var y = date.getFullYear(); var m = date.getMonth(); var d = date.getDate(); var endDate = '2013-01-04'; var array = endDate.split("-"); var endTime = new Date(parseInt(array[0]), parseInt(array[1]) - 1, parseInt(array[2])); var nowTime = new Date(parseInt(y), parseInt(m), parseInt(d)); var day = (Number(nowTime) - Number(endTime)) / (1000 * 60 * 60 * 24); alert(endDate + ' 距今已过 ' + day + ' 天');