📦 A package that lets you know how many days before that date.
You Can install by npm
$ npm install time-counting --save
or yarn
$ yarn add time-counting
// es5
const TimeCounting = require("time-counting");
const time = TimeCounting("2020-08-10");
const timecount = TimeCounting("2020-08-10 08:00:00", {
objectTime: "2020-08-10 10:00:00"
});
//es6
import TimeCounting from "time-counting";
console.log(TimeCounting("2020-08-10"));
console.log(TimeCounting("2020-08-10 08:00:00", { objectTime: "2020-08-10 10:00:00" }));
Output should be how long it is and how much is left from the current time.
2 hours ago
import TimeCounting from "time-counting";
console.log(TimeCounting("2020-08-10", { objectTime: "2020-08-11" }));
1 day ago
Name | Value | default | description |
---|---|---|---|
objectTime | Date, string, number | new Date() | It is a standard time for comparison. |
lang | "ko", "en" | "en" | language |
calculate | Calculate | Calculate | Choose how far you want the time to appear. |
Name | Value | default | Unit |
---|---|---|---|
justNow | number | 20 | second |
second | number | 60 | second |
minute | number | 60 | minute |
hour | number | 24 | hour |
day | number | 7 | day |
week | number | 4 | week |
month | number | 12 | month |
const option = {
objectTime: "2020-08-10 06:00:00",
calculate: {
justNow: 3601
}
};
console.log(TimeCounting("2020-08-10 05:00:00", option));
just now
💬 Up to 1 hour 1 second is displayed as "just now".
npm run test