修复:保险支持5张图片
This commit is contained in:
39
src/utils/time.ts
Normal file
39
src/utils/time.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* 获取当前时间
|
||||
*/
|
||||
export function formatCurrentDate() {
|
||||
// 创建一个Date对象,表示当前日期和时间
|
||||
const now = new Date();
|
||||
|
||||
// 获取年、月、日,并进行必要的格式化
|
||||
const day = String(now.getDate()).padStart(2, '0'); // 获取日,并确保是两位数
|
||||
const month = String(now.getMonth() + 1).padStart(2, '0'); // 获取月,并确保是两位数,月份是从0开始的,所以要加1
|
||||
const year = String(now.getFullYear()).slice(-2); // 获取年份的最后两位数字
|
||||
|
||||
return `${day}${month}${year}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前时分秒
|
||||
*/
|
||||
export function formatHhmmss(){
|
||||
// 创建一个Date对象,表示当前日期和时间
|
||||
const now = new Date();
|
||||
// 获取当前的小时
|
||||
const hour = String(now.getHours()).padStart(2, '0');
|
||||
// 获取当前的分钟
|
||||
const minute = String(now.getMinutes()).padStart(2, '0');
|
||||
// 获取当前的秒数
|
||||
const second = String(now.getSeconds()).padStart(2, '0');
|
||||
return `${String(Number(hour) - 8).padStart(2, '0')}${minute}${second}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前小时
|
||||
*/
|
||||
export function getCurrentHour() {
|
||||
const now = new Date();
|
||||
// 获取当前的小时
|
||||
const hour = String(now.getHours()).padStart(2, '0');
|
||||
return `${String(Number(hour) - 8).padStart(2, '0')}`;
|
||||
}
|
||||
Reference in New Issue
Block a user