<script>
function getRemainderTime (startTime){
var s1 = new Date(startTime.replace(/-/g, "/")),
s2 = new Date(),
runTime = parseInt((s2.getTime() - s1.getTime()) / 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;
// console.log(year,month,day,hour,minute,second);
return year+','+month+','+day+','+hour+','+minute+','+second;
}
//当前时间与2018-05-10的时间差
var startTime = "2018-05-10";
console.log(getRemainderTime(startTime));
</script>