1
This commit is contained in:
parent
e3c9022281
commit
a874b90b0d
16
utils.js
16
utils.js
@ -98,6 +98,21 @@ function formatDate(date) {
|
||||
(sec < 10 ? '0' + sec : sec);
|
||||
}
|
||||
|
||||
function compactFormatDate(date) {
|
||||
const year = date.getFullYear();
|
||||
const month = date.getMonth() + 1;//月份是从0开始的
|
||||
const day = date.getDate();
|
||||
const hour = date.getHours();
|
||||
const min = date.getMinutes();
|
||||
const sec = date.getSeconds();
|
||||
return year + '' +
|
||||
(month < 10 ? '0' + month : month) + '' +
|
||||
(day < 10 ? '0' + day : day) + '' +
|
||||
(hour < 10 ? '0' + hour : hour) + '' +
|
||||
(min < 10 ? '0' + min : min) + '' +
|
||||
(sec < 10 ? '0' + sec : sec);
|
||||
}
|
||||
|
||||
function pad(num, n) {
|
||||
let result = num.toString();
|
||||
let len = result.length;
|
||||
@ -361,6 +376,7 @@ exports.getUtcTime = getUtcTime;
|
||||
exports.getDaySeconds = getDaySeconds;
|
||||
exports.getHourSeconds = getHourSeconds;
|
||||
exports.formatDate = formatDate;
|
||||
exports.compactFormatDate = compactFormatDate;
|
||||
exports.pad = pad;
|
||||
exports.randRange = randRange;
|
||||
exports.randItemByWeight = randItemByWeight;
|
||||
|
Loading…
x
Reference in New Issue
Block a user