publish 功能

This commit is contained in:
Cheney
2025-03-13 11:27:11 +08:00
parent 5f5e73e1c9
commit 5ff621c05b
5 changed files with 152 additions and 76 deletions
+27
View File
@@ -0,0 +1,27 @@
module.exports = {
// 定义格式化日期的函数
formatDate : function (date){
// 获取年份
const year = date.getFullYear();
// 获取月份,注意月份是从 0 开始的,所以要加 1
const month = String(date.getMonth() + 1).padStart(2, '0');
// 获取日期
const day = String(date.getDate()).padStart(2, '0');
// 获取小时
const hours = String(date.getHours()).padStart(2, '0');
// 获取分钟
const minutes = String(date.getMinutes()).padStart(2, '0');
// 获取秒数
const seconds = String(date.getSeconds()).padStart(2, '0');
// 按照 yyyyMMddHHmmss 的格式拼接字符串
return `${year}${month}${day}${hours}${minutes}${seconds}`;
},
now : function (){
// 获取当前日期和时间
const currentDate = new Date();
// 调用格式化函数
const formattedDate = this.formatDate(currentDate);
return formattedDate
}
}