getValue: function (time1,time2){ var time1 = new Date(time1); //转换为中国标准时间 var time2 = new Date(time2); var time1 = time1.getTime(); //转换为时间戳 var time2 = time2.getTime(); var runTime = (time2 - time1) / 1000; //开始得出时间差,然后计算 var year = Math.floor(runTime / 86400 / 365); runTime = runTime % (86400 * 365); var month = Math.floor(runTime / 86400 / 30); runTime = runTime % (86400 * 30); var day = Math.floor(runTime / 86400); runTime = runTime % 86400; var hour = Math.floor(runTime / 3600); runTime = runTime % 3600; var minute = Math.floor(runTime / 60); runTime = runTime % 60; var second = runTime; return year+'年,'+month+'月,'+day+'天,'+hour+'小时,'+minute+'分,'+second+"秒"; },
帮到你了就给我点个赞吧