<html>
<head>
<meta charset="utf-8">
<title>JS日期相差天数</title>
</head>
<body>
<SCRIPT LANGUAGE="JavaScript">
var s1 = '2016-05-12';
s1 = new Date(s1.replace(/-/g, "/"));
s2 = new Date();//当前日期:2017-04-24
var days = s2.getTime() - s1.getTime();
var time = parseInt(days / (1000 * 60 * 60 * 24));
document.write(time);
</SCRIPT>
</body>
</html>