chat-timespan
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

TypeScript Library

The Problem

This Solution

Install

  yarn add chat-timespan

Usage

import TimeSpan from "chat-timespan";
 
const timeSpan = new TimeSpan();
 
timeSpan.format(new Date("2019-12-01 08:08:08").getTime()) // 2019年12月01日 08:08
timeSpan.format(Date.now() - 1000 * 60 * 60 * 2) // 2 小时前
timeSpan.format(Date.now() - 1000 * 60 * 5) // 5 分钟前
timeSpan.format(Date.now() - (1000 * 60 * 5 + 1000)) // null
timeSpan.format(Date.now() - 1000 * 60 * 2) // 2 分钟前
timeSpan.format(Date.now()) // 刚刚

API

Input :

  • timestamp: number | undefined // 时间戳

Output :

c : number | null // 时间字符串

Readme

Keywords

none

Package Sidebar

Install

npm i chat-timespan

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

7.57 kB

Total Files

9

Last publish

Collaborators

  • qinzisong