| | |
| | | const kstDate = new Date(inputDate.getTime() + 1 * 60 * 60 * 1000); // 8小时 + 1小时 = 9小时 |
| | | |
| | | // 获取年、月、日、小时、分钟和秒 |
| | | const year = kstDate.getFullYear(); |
| | | const month = kstDate.getMonth() + 1; // getMonth() 返回 0 到 11,需要加 1 |
| | | const day = kstDate.getDate(); |
| | | const hours = kstDate.getHours(); // 小时部分 |
| | | const minutes = kstDate.getMinutes(); // 分钟部分 |
| | | const seconds = kstDate.getSeconds(); // 秒部分 |
| | | const year = inputDate.getFullYear(); |
| | | const month = inputDate.getMonth() + 1; // getMonth() 返回 0 到 11,需要加 1 |
| | | const day = inputDate.getDate(); |
| | | const hours = inputDate.getHours(); // 小时部分 |
| | | const minutes = inputDate.getMinutes(); // 分钟部分 |
| | | const seconds = inputDate.getSeconds(); // 秒部分 |
| | | |
| | | // 格式化时间为“年-月-日 小时:分钟:秒”格式 |
| | | const formattedDate = `${year}-${month.toString().padStart(2, '0')}-${day.toString().padStart(2, '0')}`; |