Home > Web Front-end > JS Tutorial > JS converts seconds into hours, minutes and seconds implementation code_javascript skills

JS converts seconds into hours, minutes and seconds implementation code_javascript skills

WBOY
Release: 2016-05-16 17:23:35
Original
1405 people have browsed it
Copy code The code is as follows:

function formatSeconds(value) {
var theTime = parseInt(value );// seconds
var theTime1 = 0;// minutes
var theTime2 = 0;// hours
// alert(theTime);
if(theTime > 60) {
theTime1 = parseInt(theTime/60);
theTime = parseInt(theTime`);
// alert(theTime1 "-" theTime);
if(theTime1 > 60) {
theTime2 = parseInt(theTime1/60);
theTime1 = parseInt(theTime1`);
}
}
var result = "" parseInt(theTime) "seconds";
if(theTime1 > ; 0) {
result = "" parseInt(theTime1) "minutes" result;
}
if(theTime2 > 0) {
result = "" parseInt(theTime2) "hour" result ;
}
return result;
}
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template