js把毫秒轉換為 xx小時xx分鐘xx秒的通用方法

   function MillisecondToDate(msd) {
        var time = parseFloat(msd) /1000;
        if (null!= time &&""!= time) {
            if (time >60&& time <60*60) {
                time = parseInt(time /60.0) +"分鐘"+ parseInt((parseFloat(time /60.0) –
                parseInt(time /60.0)) *60) +"秒"; www.aiwalls.com
            }else if (time >=60*60&& time <60*60*24) {
                time = parseInt(time /3600.0) +"小時"+ parseInt((parseFloat(time /3600.0) –
                parseInt(time /3600.0)) *60) +"分鐘"+
                parseInt((parseFloat((parseFloat(time /3600.0) – parseInt(time /3600.0)) *60) –
                parseInt((parseFloat(time /3600.0) – parseInt(time /3600.0)) *60)) *60) +"秒";
            }else {
                time = parseInt(time) +"秒";
            }
        }else{
            time = "0 時 0 分0 秒";
        }
        return time;

    }

作者:zhanghu198901

You May Also Like