JS 获取日期相差天数

var s1 = '2012-05-12';

s1 = new Date(s1.replace(/-/g, "/"));
s2 = new Date();

var days = s2.getTime() - s1.getTime();
var time = parseInt(days / (1000 * 60 * 60 * 24));

posted @ 2012-05-15 10:34  二姐1511  阅读(33793)  评论(0编辑  收藏  举报