代码拉取完成,页面将自动刷新
A JavaScript time helper toolkit.
npm i @knno/time
import time from "@knno/time";
console.log(time.now()); // get current time equal to new Date()
console.log(time.moment(200000)); // get description string of a time duration: xxx days xxx hours xxx minutes xxx seconds
console.log(time.moment(200000), { maxUnit: "h" }); // biggest unit is hour
console.log(time.moment(200000), { minUnit: "m" }); // smallest unit is minute
// available unit are 'd', 'h', 'm', 's'
console.log(time.interval("2019-1-1", "2020-2-10", "d"));
// available unit are 'd', 'h', 'm', 's', 'ms'
console.log(time.add("2019-1-1", 30, "d"));
// available unit are 'd', 'h', 'm', 's', 'ms'
console.log(time.dayOfYear(new Date()));
console.log(time.daysOfMonth(new Date())); // get total days of month
console.log(time.parse('2019-1-12'));
console.log(time.parse('2019-1-12 22:22:00'));
console.log(time.parse('2019-1-12T22:22:00+0800'));
console.log(time.parse('2019-1-12T22:22:00Z'));
console.log(time.parse('1/1/2020'));
console.log(time.parse('Jan 1, 2020'));
......
// if some format cannot be auto detect, you can specify format manually
console.log(time.parse('2019年5月31日 20:08:30', 'yyyy年M月d日 hh:mm:ss'));
console.log(time.format(time.now()); // use default format ISO8601 to convert to string
console.log(time.format(time.now(), 'yyyy年MM月dd日'); // use custom format to convert
......
That's all
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。