時間に分と秒に秒数をJS

関数formatSeconds(値){ 
    VAR theTime =のparseInt(値); //秒
    VAR theTime1 = 0; //分
    VAR theTime2 = 0; //小时
    IF(theTime> 60){ 
        theTime1 =のparseInt(theTime / 60)。
        theTime =のparseInt(theTime 60%)。
        IF(theTime1> 60){ 
            theTime2 =のparseInt(theTime1 / 60)。
            theTime1 =のparseInt(theTime1 60%)。
        } 
    } 
    VAR結果= "" +のparseInt(theTime)。
    (結果<10){もし
    	結果= '0' +結果。
    } 
    (theTime1> 0){もし
        結果= "" +のparseInt(theTime1)+ ":" +結果。
        IF(theTime1 <10){
        	結果=「0」+結果。
        }
    }他{ 
    	結果= '00」+結果。
    } 
    (theTime2> 0){もし
        結果= "" +のparseInt(theTime2)+ ":" +結果。
        (theTime2 <10){もし
        	結果= '0' +結果。
        } 
    }他{ 
    	結果= '00」+結果。
    } 
    結果を返します。
}

  

おすすめ

転載: www.cnblogs.com/xiaomingliu/p/12449571.html