javascriptは秒数を時分秒に換算します.
3019 ワード
<script language="javascript">
/**
*
* :
*/
function formatSeconds(value) {
var secondTime = parseInt(value);//
var minuteTime = 0;//
var hourTime = 0;//
if(secondTime > 60) {// 60,
// , 60 ,
minuteTime = parseInt(secondTime / 60);
// , ,
secondTime = parseInt(secondTime % 60);
// 60,
if(minuteTime > 60) {
// , 60,
hourTime = parseInt(minuteTime / 60);
// , 60
minuteTime = parseInt(minuteTime % 60);
}
}
var result = "" + parseInt(secondTime) + " ";
if(minuteTime > 0) {
result = "" + parseInt(minuteTime) + " " + result;
}
if(hourTime > 0) {
result = "" + parseInt(hourTime) + " " + result;
}
return result;
}
console.log(formatSeconds(10000002))
script>
出力は2777時間46分42秒です.