/**
* 转为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. 【Java】学习路径55-练习:制作一个聊天室(多线程、UDP、双向传输数据)

    创建四个类,实现双向聊天的功能. 接收线程: import java.io.IOException; import java.net.*; public class ReceiveThread imp ...

  2. 【必知必会】手把手教你配置MySQL环境变量——图文详解

    一.先决条件 假设我们已经成功安装MySQL数据库.如果还有小伙伴不知道如何安装MySQL数据库,可以在本文下留言,留言数超20,则出一期"手把手教你安装MySQL数据库--图文详解&quo ...

  3. Centos_yum使用

    安装应用 yum install -y xxx -y 表示自动yes 卸载应用 yum -y remove xxx -y 表示自动yes 查看已安装的应用 yum list installed

  4. 【设计模式】Java设计模式 - 原型模式

    [设计模式]Java设计模式 - 原型模式 不断学习才是王道 继续踏上学习之路,学之分享笔记 总有一天我也能像各位大佬一样 原创作品,更多关注我CSDN: 一个有梦有戏的人 准备将博客园.CSDN一起 ...

  5. 基于 Apache Hudi + Presto + AWS S3 构建开放Lakehouse

    认识Lakehouse 数据仓库被认为是对结构化数据执行分析的标准,但它不能处理非结构化数据. 包括诸如文本.图像.音频.视频和其他格式的信息. 此外机器学习和人工智能在业务的各个方面变得越来越普遍, ...

  6. 重新安装kuboard后,原先配置的CI/CD命令都没了,需要重新创建

    背景介绍 使用如下命令创建的kuboard服务,上一层用nginx设置代理,用域名访问使用的 docker run -d \ --restart=always \ --name=kuboard \ - ...

  7. Centos7主机安装Cockpit管理其他主机

    前提条件:需要管理的每台服务器上都需要安装cockpit 假设Centos7主机安装Cockpit的为A,其他主机为B 如果B上有A的公钥,那么直接连接至B,否则,输入B的用户名密码连接. 问题:在A ...

  8. Gitlab基础知识介绍

    GitLab架构图 Gitlab各组件作用 -Nginx:静态web服务器. -gitlab-shell:用于处理Git命令和修改authorized keys列表. -gitlab-workhors ...

  9. 货币转换I

    A=input() if A[0] in ['U','u']: RMB=(eval(A[3:]))*6.78 print("RMB{:.2f}".format(RMB)) else ...

  10. 编写一个应用程序,在主类Test1类中,创建两个链表List<E>对象,分别存储通过键盘输入的字符串内容

    题目1:编写一个应用程序,在主类Test1类中,创建两个链表List<E>对象,分别存储通过键盘输入的字符串内容--"chen","wang",&q ...