[github地址:https://github.com/ABCDdouyae...]

pretty-ms

将毫秒转换为容易读取的时间:1337000000 → 15d 11h 23m 20s

普通用法

用法:prettyMs(milliseconds)

返回:string

第二参数用法

用法:prettyMs(milliseconds, options|object)

返回:string

  • secDecimalDigits:秒数后面保留的小数点位数,默认1
prettyMs(21312, {secDecimalDigits: 2});//21.32s
  • msDecimalDigits:毫秒后面保留的小数点位数,默认0,与process.hrtime()结合使用
  • keepDecimalsOnWholeSeconds:保证输出的秒数宽度不变,默认false
prettyMs(20000, {keepDecimalsOnWholeSeconds: true });
//20.0s
  • compact:仅展示第一个单位的值,默认false
prettyMs(123232, {compact: true});//~2m
  • unitCount:要展示的单位个数,compact为true会覆盖此选项,默认:infinity
prettyMs(12312312, {unitCount: 2})//~3h 25m
  • verbose:使用全拼的单位,默认false
prettyMs(12312312, {verbose: true});
// 3 hours 25 minutes 12.3 seconds
  • separateMs:最小单位为毫秒数,默认false
prettyMs(12312312, {separateMs: true});// 3h 25m 12s 312ms
  • formatSubMs: 显示微秒和纳秒部分,默认false
prettyMs(12312312.12323, {formatSubMs: true});//3h 25m 12s 312ms 123µs 230ns
prettyMs(12312312.12323, {formatSubMs: true, verbose: true});
//3 3 hours 25 minutes 12 seconds 312 milliseconds 123 microseconds 230 nanoseconds

【每日一包0017】pretty-ms的更多相关文章

  1. 【每日一包0005】arr-flatten

    github地址:https://github.com/ABCDdouyae... arr-flatten 将多维数组展开成一维数组 文档地址:https://www.npmjs.com/packag ...

  2. 【每日一包0018】fecha

    [github地址:https://github.com/ABCDdouyae...] fecha 比moment.js更加轻量级的时间解析和格式化包 format 用法:format(<Dat ...

  3. 【每日一包0011】pad

    [github地址:https://github.com/ABCDdouyae...] pad 给字符串的左右加padding,也可以用于删减字符串两端 用法:pad(str, length, opt ...

  4. 【每日一包0015】gradient-string

    [github地址:https://github.com/ABCDdouyae...] gradient-string 用于在终端打印出好看的渐变文字 普通用法 console.log(gradien ...

  5. 【每日一包0001】is-sorted

    github地址:https://github.com/ABCDdouyae... is-sorted 用于判断数组是否被排序了 文档地址:https://www.npmjs.com/package/ ...

  6. 【每日一包0003】kind-of

    github地址:https://github.com/ABCDdouyae... kind-of 判断数据类型用法:kind-of(date)返回:string 数据类型 January undef ...

  7. 【每日一包0008】arr-diff

    [github地址:https://github.com/ABCDdouyae...] arr-diff 多个数组比较,过滤出第一个数组独有的内容 用法:arr-diff(arr1, arr2, ar ...

  8. 【每日一包0009】group-array

    [github地址:https://github.com/ABCDdouyae...] group-array 对数组里面的多项按照指定的key进行整合 用法:group-array(arr, key ...

  9. 【每日一包0012】to-camel-case,to-no-case,to-space-case

    github地址:https://github.com/ABCDdouyaer/a_pack_per_day_NO.1 to-camel-case 将被其他符号分割的字符串转换为驼峰形式的字符串 用法 ...

随机推荐

  1. Python2 和 Python3的区别 更新中

    py2和py3的区别 1.默认解释器编码 py2: ascii py3: utf-8 2.输入 输出 输入 py2: name = raw_input('请输入你的姓名:') py3: name = ...

  2. [HNOI2003]操作系统 优先队列用法

    题:https://www.cometoj.com/problem/1046 #include<bits/stdc++.h> using namespace std; typedef lo ...

  3. 提高线程数,解决redis超时问题

    根据压测结果做出的修改历史: 第一步:只针对maxWorkerThreads.maxIoThreads和minWorkerThreads做了修改<processModel autoConfig= ...

  4. CentOS-TFTP服务搭建

    title date tags layout CentOS6.5 TFTP搭建 2018-08-26 Centos6.5服务器搭建 post 1.安装TFTP服务 yum install tftp-s ...

  5. EX_KMP算法总结

    EX_KMP算法总结 By viv 2014-8-9 0:30 吐槽1:字符串神马的我最讨厌了,但不学不行啊.TAT 吐槽2:写这东西差点错过CF(codeforces). 今天学了ex_kmp,故总 ...

  6. PLC常见四大故障及其处理方法

    众所周知,PLC即可编程控制器,是一种专门为在工业环境下应用而设计的数字运算操作的电子装置. 但PLC在运行中总是会出现一些故障问题,下面就为大家介绍一下PLC常见四大故障及其处理方法 PLC常见四大 ...

  7. Anaconda 安装、TensorFlow 安装、pytorch 安装

    问题 1 假设已经安装完Anaconda Navigator,按照 网址:https://www.zhihu.com/question/55577586 的教程操作,设置镜像源地址,安装. 问题 2: ...

  8. Hypothesis Tests for One Population Mean When σ Is Unknown|other

    9.5 Hypothesis Tests for One Population Mean When σ Is Unknown 使用t分布: What If the Assumptions Are No ...

  9. jQuery插件开发小结

    jQuery插件开发规范 1. 使用闭包 (function($) { // Code goes here })(jQuery); 这是来自jQuery官方的插件开发规范要求,使用这种编写方式有什么好 ...

  10. ip获取到城市

    <?phpfunction GetIP() {    if ($_SERVER["HTTP_X_FORWARDED_FOR"])        $ip = $_SERVER[ ...