0.2.8 • Published 6 years ago

@fir-ui/date-formatter v0.2.8

Weekly downloads
1
License
MIT
Repository
-
Last release
6 years ago

fir-date-formatter

一个短小精悍的日期时间格式化工具。

📥 安装

Node

yarn add @fir-ui/date-formatter

CDN

<script src="//unpkg.com/@fir-ui/date-formatter"></script>

CDN 引入时,可通过全局变量 firDateFormatter 使用。

🔧 使用

基本用法:传入 Date 实例

var date = new Date()

console.log(
  firDateFormatter(
    date,
    'yy年mm月dd日 hh时ii分ss秒l毫秒'
  )
)

输出类似这样:

18年04月12日 06时13分53秒390毫秒

高级用法:自定义占位符及其对应的值

console.log(
  firDateFormatter(
    {
      x: 1000,
      y: 2,
      z: 1002
    },
    'x + y = z (i > 0)'
  )
)

输出类似这样:

1000 + 2 = 1002 (i > 0)

🔡 日期时间占位符

占位符说明例子
y年 (year)y --> 2018yy --> 18yyyy --> 2018
m月 (month)m --> 5mm --> 05
d日 (day)d --> 4dd --> 04
h时 (hour)h --> 8hh --> 08
i分 (minute)i --> 6ii --> 06
s秒 (second)s --> 1ss --> 01
l毫秒 (millisecond)l --> 750
0.2.8

6 years ago

0.2.6

6 years ago

0.2.5

6 years ago

0.2.4

6 years ago

0.2.3

6 years ago

0.2.2

6 years ago

0.1.1

6 years ago

0.0.1

6 years ago