国内外VPS
主机测评与优惠

JS计算两个时间戳相差月数、天数、时数、分钟、秒数

  function humandate(time1,time2){  //var time1 = Date.parse(new Date()) / 1000;  var s = time1 - time2;  if(s<0){  s = Math.abs(s);  }  if(s > 31536000) {    return formatDate(new Date(time2 * 1000));  } else if(s > 2592000) {    return parseInt(s / 2592000) + '月';  } else if(s > 86400) {    return parseInt(s / 86400) + '天';  } else if(s > 3600) {    return parseInt(s / 3600) +'小时';  } else if(s > 60) {    return parseInt(s / 60)+'分钟';  } else {    return parseInt(s)+'秒';  }  }

赞(0)
版权声明:本文采用知识共享 署名4.0国际许可协议 [BY-NC-SA] 进行授权
文章名称:《JS计算两个时间戳相差月数、天数、时数、分钟、秒数》
文章链接:https://www.liuzhanwu.com/3252.html
本站资源仅供个人学习交流,请于下载后24小时内删除,不允许用于商业用途,否则法律问题自行承担。

登录

找回密码

注册