js 计算相差多少天

<script type="text/javascript">
        var s1 = '2012-11-11 00:00:00';

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

        var days = s2.getTime() - s1.getTime();
        var time = parseInt(days / (1000 * 60 * 60 * 24));
        document.write("相差" + time + "");
    </script>

 

posted @ 2012-12-11 14:32  doubledu  阅读(185)  评论(0编辑  收藏  举报