/**
* 转为HH:MM:SS
* @param second
* @returns {string}
* @private
*/
var _showTime = function (second) {
if (second < 60) {
if (second < 10) {
return "00:00:0" + second;
} else {
return "00:00:" + second;
}
} else {
var min_total = Math.floor(second / 60); // 分钟
var sec = Math.floor(second % 60); // 余秒
if (min_total < 60) {
if (min_total < 10) {
if (sec < 10) {
return "00:0" + min_total + ":0" + sec;
} else {
return "00:0" + min_total + ":" + sec;
}
} else {
if (sec < 10) {
return "00:" + min_total + ":0" + sec;
} else {
return "00:" + min_total + ":" + sec;
}
}
} else {
var hour_total = Math.floor(min_total / 60); // 小时数
if (hour_total < 10) {
hour_total = "0" + hour_total;
}
var min = Math.floor(min_total % 60); // 余分钟
if (min < 10) {
min = "0" + min;
}
if (sec < 10) {
sec = "0" + sec;
}
return hour_total + ":" + min + ":" + sec;
}
}
} /**
* 转换时间格式为xx小时xx分xx秒
* @param time HH:MM:SS
*/
function changeTimeFormat(time) {
var timeList = [];
timeList = time.split(":");
console.log(timeList)
if (timeList[0] == '00') {
if (timeList[1] == '00') {
return timeList[2] + "秒";
} else {
if (timeList[2] == '00') {
return timeList[1] + "分";
} else {
return timeList[1] + "分" + timeList[2] + "秒";
}
}
} else {
if (timeList[1] == '00') {
if (timeList[2] == '00') {
return timeList[0] + "小时";
} else {
return timeList[0] + "小时" + timeList[2] + "秒";
}
} else {
if (timeList[2] == '00') {
return timeList[0] + "小时" + timeList[1] + "分";
} else {
return timeList[0] + "小时" + timeList[1] + "分" + timeList[2] + "秒";
}
}
}
}

js把秒数转换为HH:MM:SS及时分秒格式的更多相关文章

  1. 将秒数转为HH:MM:SS格式的时间

    /**  * 将秒数转为HH:MM:SS格式的时间  * @param $seconds  * @return string  */ public static function GetHHMMSSB ...

  2. SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式

    java日期格式大全 format SimpleDateFormat(转) SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH ...

  3. js获取当前日期时间“yyyy-MM-dd HH:MM:SS”

    获取当前的日期时间 格式“yyyy-MM-dd HH:MM:SS” 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 function getNowFormatDat ...

  4. 【转】js获取当前日期时间“yyyy-MM-dd HH:MM:SS”

    获取当前的日期时间 格式“yyyy-MM-dd HH:MM:SS”   1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 function getNowFormatD ...

  5. dd/MMM/yyyy:hh:mm:ss +0800日期格式的转化

    private static void myHandler() throws ParseException { String dtime1 = "23/Apr/2019:04:08:00 + ...

  6. JS中如何将yyyy-MM-dd HH:mm:ss格式的字符串转成Date类型

    var deadline = '2019-04-11 13:11:00';   var result = new Date(deadline.replace(/-/g, '/'));

  7. hh:mm:ss时间格式那些事儿

    怎么把hh:mm:ss.45 时间格式换算成秒? 比较简单点的格式,比如hh:mm:ss是比较容易的,但是怎么样把hh:mm:ss.45,这样的格式,就是秒不是整数的时间格式换算成秒? ans:将时间 ...

  8. SimpleDateFormat 中的yyyy-MM-dd HH:mm:ss.SSS说明

    SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 转换的格式:yyyy是完整的西元年,MM是月份, ...

  9. yyyy-MM-dd'T'HH:mm:ss.SSS'Z'即UTC时间,与String日期转换

    本文为博主原创,未经允许不得转载: 最近在使用一个时间插件的时候,接收到的时间格式是 ’2017-11-27T03:16:03.944Z’ ,当我进行双向数据绑定的时候,由后台传过来的时间绑定到时间 ...

随机推荐

  1. C#基础_XML文件读写

    使用C#对XML文件进行操作,包括生成一个XML文档,以及读取XML文档中的内容,修改某个元素中的内容 using System; using System.Collections.Generic; ...

  2. Java开发学习(二十七)----SpringMVC之Rest风格解析及快速开发

    一.REST简介 REST(Representational State Transfer),表现形式状态转换,它是一种软件架构风格 当我们想表示一个网络资源的时候,可以使用两种方式: 传统风格资源描 ...

  3. Android下的IPC通信方式

    一.Bundle Android的Activity.Service.Receiver都支持在Intent传递Bundle数据,Bundle实现了Parcelable接口, 所以能很方便的在不同进程之间 ...

  4. 【面试题】js实现将excel表格copy到页面

    js实现将excel表格copy到页面 点击打开视频讲解更加详细 其实最核心的技术,还是copy的是我们粘贴板上的数据 就像平常怎么粘贴复制其他的数据一样,只是我们在excel粘贴的是一个表格数据 这 ...

  5. Springboot log4j2总结

    Log4j2 PS: Log4j 已不再维护,而最新的是Log4j2, Log4j2 是全部重写了Log4j,并拥有更加优秀的性能 1. 引入依赖,和去掉logging的依赖 <dependen ...

  6. 升级Windows 2003域控制器到Windows 2012 R2

    由于Windows 2003包括R2的扩展支持在今年7月14日就会过期.如果在扩展周期结束之前没有和微软签订昂贵服务协议,那么系统将得不到任何补丁和技术支持. 我这里准备了两台测试用的机器做这个实验. ...

  7. shell分割字符串并赋值给变量

    假如变量var的值为:num=12,也即var="num=12",现在想把 12赋值给变量id awk 的-F 后跟上要分割字符串时的指定分隔符 awk中$0是要分割的字符串,$1 ...

  8. 单台主机MySQL多实例部署

    二进制安装mysql-5.7.26 [root@mysql ~]# cd /server/tools/ [root@mysql tools]# ll total 629756 -rw-r--r-- 1 ...

  9. Compose 模板文件

    模板文件是使用 Compose 的核心,涉及到的指令关键字也比较多.但大家不用担心,这里面大部分指令跟 docker run 相关参数的含义都是类似的. 默认的模板文件名称为 docker-compo ...

  10. JS 模块化- 04 CMD 规范与 Sea JS

    1 CMD 规范介绍 CMD: Common Module Definition, 通用模块定义.与 AMD 规范类似,也是用于浏览器端,异步加载模块,一个文件就是一个模块,当模块使用时才会加载执行. ...