通过new Dtae()方法实现获取当前时间
const date = new Date(); const year = date.getFullYear(); const month = date.getMonth() + 1; //JS月份是从0开始的需1 const day = date.getDate(); const hours = date.getHours().toString().padStart(2, "0"); const minutes = date.getMinutes().toString().padStart(2, "0"); const NowDate = `${year}-${month}-${day}-${hours}:${minutes}`;
JavaScript获取当前时间
最新推荐文章于 2024-08-27 16:06:05 发布