JS將秒換成時分秒實現(xiàn)代碼
更新時間:2013年09月03日 18:22:17 作者:
將秒換成時分秒的方法有很多,在本文將為大家介紹下,使用js的具體的實現(xiàn)思路,有需要的朋友可以參考下,希望對大家有所幫助
復(fù)制代碼 代碼如下:
function formatSeconds(value) {
var theTime = parseInt(value);// 秒
var theTime1 = 0;// 分
var theTime2 = 0;// 小時
// alert(theTime);
if(theTime > 60) {
theTime1 = parseInt(theTime/60);
theTime = parseInt(theTime%60);
// alert(theTime1+"-"+theTime);
if(theTime1 > 60) {
theTime2 = parseInt(theTime1/60);
theTime1 = parseInt(theTime1%60);
}
}
var result = ""+parseInt(theTime)+"秒";
if(theTime1 > 0) {
result = ""+parseInt(theTime1)+"分"+result;
}
if(theTime2 > 0) {
result = ""+parseInt(theTime2)+"小時"+result;
}
return result;
}
相關(guān)文章
Egg.js 中 AJax 上傳文件獲取參數(shù)的方法
這篇文章主要介紹了Egg.js 中 AJax 上傳文件獲取參數(shù),需要的朋友可以參考下2018-10-10
Three.js獲取鼠標(biāo)點擊的三維坐標(biāo)示例代碼
本篇文章主要介紹了Three.js獲取鼠標(biāo)點擊的三維坐標(biāo)示例代碼。具有一定的參考價值,感興趣的小伙伴們可以參考一下。2017-03-03
外部web端訪問微信小程序云數(shù)據(jù)庫的三種方法總結(jié)
最近在研究微信小程序的云開發(fā)功能,下面這篇文章主要給大家介紹了關(guān)于外部web端訪問微信小程序云數(shù)據(jù)庫的三種方法,文中通過實例代碼介紹的非常詳細(xì),需要的朋友可以參考下2022-04-04
JS庫之Particles.js中文開發(fā)手冊及參數(shù)詳解
因為自己需要做產(chǎn)品,所以一個好的UI界面也是很重要的,發(fā)現(xiàn)這種散射的原子顆粒特效還不錯。今天腳本之家小編把Particles.js中文開發(fā)手冊及particles.js參數(shù)分享給大家,需要的朋友參考下吧2017-09-09

