js格式化秒数
2017-04-19 14:41
103 查看
function formatTime(value)
{
var theTime = parseInt(value);// 秒
var theTime1
= 0;// 分
var theTime2
= 0;// 小时
if(theTime
> 60) {
theTime1 = parseInt(theTime/60);
theTime = parseInt(theTime`);
if(theTime1 > 60) {
theTime2 = parseInt(theTime1/60);
theTime1 = parseInt(theTime1`);
}
}
var result =
"";
if(theTime
> 0){
result = ""+parseInt(theTime)+"秒";
}
if(theTime1
> 0) {
result = ""+parseInt(theTime1)+"分"+result;
}
if(theTime2
> 0) {
result = ""+parseInt(theTime2)+"小时"+result;
}
return
result;
}
{
var theTime = parseInt(value);// 秒
var theTime1
= 0;// 分
var theTime2
= 0;// 小时
if(theTime
> 60) {
theTime1 = parseInt(theTime/60);
theTime = parseInt(theTime`);
if(theTime1 > 60) {
theTime2 = parseInt(theTime1/60);
theTime1 = parseInt(theTime1`);
}
}
var result =
"";
if(theTime
> 0){
result = ""+parseInt(theTime)+"秒";
}
if(theTime1
> 0) {
result = ""+parseInt(theTime1)+"分"+result;
}
if(theTime2
> 0) {
result = ""+parseInt(theTime2)+"小时"+result;
}
return
result;
}
相关文章推荐
- 初学knockout js
- jsonDoc.AddMember
- rapidjson 使用
- js fuction函数内return一个内部函数详解
- FastJson--阿里巴巴公司开源的速度最快的Json和对象转换工具
- JavaScript了解,js的插入
- Json的简单使用
- 简易图书管理系统(主要是jsp+servlet的练习)
- Javascript创建对象的学习和使用
- Javascript正则表达式的初步学习
- Javascript实现计数器,定时警告和停止
- Javascript提升阶段学习
- Javascript中DOM技术的的简单学习
- Javascript中String对象的的简单学习
- Javascript函数的简单学习
- Javascript入门学习
- JSP标签
- 跟我学JavaScript--事件,输出
- 图片局部放大原生js,html代码
- js验证ip地址是否有效