美文网首页
计算两个时间的相差天数(兼容IE chrome firefox)

计算两个时间的相差天数(兼容IE chrome firefox)

作者: 羊绘霖 | 来源:发表于2018-05-02 14:30 被阅读0次

function datedifference(sDate1, sDate2) {   //sDate1和sDate2是2006.12.18格式

    sDate1=sDate1.replace(/\./g,"/");

    var startdate=new Date(sDate1);

    sDate2=sDate2.replace(/\./g,"/");

    var enddate=new Date(sDate2);

    var time=startdate.getTime()-enddate.getTime();

    var days=parseInt(Math.abs(time)/(1000 * 60 * 60 * 24));

        return days

    };

相关文章

网友评论

      本文标题:计算两个时间的相差天数(兼容IE chrome firefox)

      本文链接:https://www.haomeiwen.com/subject/gyhcrftx.html