JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q22587F
  • License MIT

'日期格式化工具'

Package Exports

  • forenoon

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (forenoon) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

时间日期格式化工具

安装

npm i foremoon --save
npm install

引入

const foremoon = require('foremoon')import foremoon from 'foremoon'

使用方法

  • 格式化时间
    foremoon.fmtDateArea(options)
    options参数:

    参数名 格式 默认值 说明
    date '2019年11月23日 17:42:19' 或者 1577094139529 new Date() 传日期形式需要传入字符串,时间戳要转成Number
    fmtType full full 返回格式:2019-11-23 18:18:58
    ymd 年月日,返回格式:2019-11-23
    hms 时分秒,返回格式:18:22:04
    chn 中文年月日,返回格式:2019年11月23日 18:22:33
    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')