赞
踩
const nowTime = new Date();
// 获取当前时间的年、月、日、时、分、秒
const year = nowTime.getFullYear();
const month = nowTime.getMonth() + 1; // 月份从0开始,所以需要加1
const day = nowTime.getDate();
const hours = nowTime.getHours();
const minutes = nowTime.getMinutes();
const seconds = nowTime.getSeconds();
// 格式化时间字符串
const formattedTime = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。