Licence
MIT
Version
1.0.5
Deps
1
Size
5 kB
Vulns
0
Weekly
0
时间日期格式化工具
安装
npm i foremoon --save
npm install
引入
const foremoon = require('foremoon')
或
import foremoon from 'foremoon'
使用方法
格式化时间
foremoon.fmtDateArea(options)options参数:参数名 格式 默认值 说明 date '2019年11月23日 1719' 或者 1577094139529 new Date() 传日期形式需要传入字符串,时间戳要转成Number fmtType full full 返回格式:2019-11-23 1858 ymd 年月日,返回格式:2019-11-23 hms 时分秒,返回格式:1804 chn 中文年月日,返回格式:2019年11月23日 1833 connector -、/ - 年月日连接符 获取一段时间
foremoon.fmtDateArea(type, fmtType)type参数参数名 返回值 week [ '2019-12-22', '2019-12-28' ] month [ '2019-12-01', '2019-12-31' ] year '2019-01-01', '2019-12-31' ] fmtType参数:参数名 返回值 'YYYY-MM-DD' [ '2019-12-22', '2019-12-28' ] 'YYYY/MM/DD' [ '2019/12/22', '2019/12/28' ] fmtType的参数可参照momentjs格式获取N天前的日期
foremoon.datePreEnd(dayCount, type='day', fmtType)示例:
foremoon.datePreEnd(7, 'day', 'YYYY-MM-DD')