Bitment
A tiny time format lib
install
npm i bitment -S
Usage
As CommonJs module
const Bitment = require('bitment');
const today = new Bitment().format('YYYY-MM-DD');
As ES module
import Bitment from 'bitment';
const today = new Bitment().format('YYYY-MM-DD');
Documentation
Paramters
Bitment inherit Date instance. So the paramters are the same as Date instance.
Methods
format(template)
- Arguments:
- {string} template
- Usage:
Format a time template string.
new Bitment().format('YYYY-MM-DD'); // YYYY -> Year // MM -> Month // DD -> Day // hh -> Hour // mm -> Minute // ss -> Second
getMap()
- Usage:
Get the object of time.
new Bitment().getMap(); // { year: '..', month: '..', day: '..', ... }
getDiff
- Usage:
Get the description of time difference.
new Bitment(Date.now() - 20000000).getDiff(); // 5小时前
LICENSE
MIT