1.1.0 • Published 1 year ago

zk-format v1.1.0

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

安装

npm install zk-format

导入

const zkFormat = require("zk-format");

使用

//将传入的事件格式化成"yyyy-MM-dd hh:mm:ss.S" 或"yyyy-M-d h:m:s.S"字符串
const d = zkFormat.formatTimeToStr(new Date(), "yyyy-MM-dd hh:mm:ss");
// log  2023-02-13 14:31:28

//获得该月的天数
const d = zkFormat.getMonthDays("2023", "2");
// log  28

//获得本季度的起止日期
const d = zkFormat.getCurrentSeason();
//log [ '2023-01-01', '2023-03-31' ]

//获得本月的起止时间
const d = zkFormat.getCurrentMonth();
//log  [ '2023-02-01', '2023-02-28' ]

//获得本周的起止时间
const d = zkFormat.getCurrentWeek();
//log [ '2023-02-12', '2023-02-18' ]

//获得本年的起止时间
const d = zkFormat.getCurrentYear();
//log [ '2023-01-01', '2023-12-31' ]

//获得当前天
const d = zkFormat.getCurrentDay();
//log [ '2023-02-13', '2023-02-13' ]

//获得当前日期是星期几
const d = zkFormat.getWeekDay(new Date());
// log 星期一

//根据身份证查询年龄
const str = zkFormat.getAgeByIdCard("411327199701166840");
// log 26

//根据出生日期计算年龄
const str = zkFormat.getAge("2000-01-01");
//log 23岁

开源协议

"ISC"

1.1.0

1 year ago

1.0.0

1 year ago