当前位置: 代码迷 >> JavaScript >> javascript 怎么 处理日期
  详细解决方案

javascript 怎么 处理日期

热度:148   发布时间:2012-10-20 14:12:48.0
javascript 如何 处理日期


var s1 = "2007-01-01";
var s2 = "2007-12-31";
s1 = s1.replace(/-/g, "/");
s2 = s2.replace(/-/g, "/");

s1 = new Date(s1);
s2 = new Date(s2);
var days= s1.getTime() - s2.getTime();

var time = parseInt(days / (1000 * 60 * 60 * 24));
alert("相差天数: " + days);
  相关解决方案