hello-date

1.0.4 • Public • Published

hello-date v1.0.4

时间日期转化工具,可将日期或时间戳转化为timeago等

npm install hello-date --save

直接页面引入

<script src="./dist/helloDate.js"></script>

模块引入

import helloDate from 'hello-date'

or

var helloDate = require('hello-date')

API

helloDate.timeago

// 参数可以是时间戳或者日期格式的字符串
var ago = helloDate.timeago('2018-6-10')  // 2个月前
var ago = helloDate.timeago(1528560000)   // 2个月前

helloDate.yesterday

// 参数可以是时间戳或者日期格式的字符串
// 超过48小时显示日期,48小时以内显示时间
var yesterday = helloDate.yesterday('2018-6-10')  // 昨天15:30
var yesterday = helloDate.yesterday(1528560000)   // 昨天15:30

helloDate.toTimestamp

// 参数为日期格式的时间
var timestamp = helloDate.toTimestamp('2018-6-10 21:32:20') // 1528637540

helloDate.toDate

// 参数为时间戳
var date = helloDate.toDate(1528637540)  // 2018-6-10 21:32:20

Readme

Keywords

Package Sidebar

Install

npm i hello-date

Weekly Downloads

0

Version

1.0.4

License

ISC

Unpacked Size

12.4 kB

Total Files

6

Last publish

Collaborators

  • sangshaofeng