function getContinueTime(startTime) { //当前时间与指定的时间的差值 var time = (new Date() - new Date(startTime)) / 1000, serviceTime = ‘‘, days = Math.floor(time / 3600 / 24), hours = Math.floor(time / 3600 % 24), minutes = Math.floor(time / 60 % 60), seconds = Math.floor(time % 60); hours = hours && hours < 10 ? ‘0‘ + hours : hours; minutes = minutes && minutes < 10 ? ‘0‘ + minutes : minutes; seconds = seconds && seconds < 10 ? ‘0‘ + seconds : seconds; days ? serviceTime += days + ‘天‘ : ‘‘; hours ? serviceTime += hours + ‘时‘ : ‘‘; minutes ? serviceTime += minutes + ‘分‘ : ‘‘; serviceTime += seconds + ‘秒‘; return serviceTime } getContinueTime(‘2015/01/01‘);
时间: 2024-10-10 03:05:40