1.0.3 • Published 3 years ago
time-magic v1.0.3
一个极简的时间处理包
简介
一个比dayjs更为精简的时间处理包
- 包含如下方法:
formatTime:提供时间转化成指定格式的字符串(可指定格式)
```
/**
* @param {*} 时间 格式字符串
* @return {*} string
*/
```
getDescription:获得输入时间距现在时间长短的文字描述
```
/**
* @param {*} 时间字符串或时间戳 格式字符串
* @return {*} string
*/
```
安装 npm i time-magic
示例
const { formatTime, getDescription } = require('time-magic') // 精确到秒 const timeStr = formatTime(new Date(), "{y}-{m}-{d} {h}:{i}") console.log(timeStr) // 输入时间距当前时间的文字描述 const dis = getDescription(new Date(1621660658550)) console.log(dis)