let time = new Date(); // 当前时间
let y = time.getFullYear(); // 年
let M = time.getMonth() + 1; // 月
let d = time.getDate(); // 日
let h = time.getHours(); // 时
let m = time.getMinutes(); // 分
let s = time.getSeconds(); // 秒
const now = new Date().getTime(); // 获取当前时间并转换为毫秒
const date = new Date().getDate(); // 获取当前日
const nowTime = new Date().toLocaleString(); // 获取当前时间2022/4/18 15:39:31
当前时间转换成日期格式
最新推荐文章于 2023-03-06 15:11:50 发布
这篇博客展示了如何使用JavaScript获取当前日期、时间,并将其转化为不同格式,包括年、月、日、时、分、秒以及毫秒。还提到了如何获取当前日期、时间的字符串表示。内容主要涉及基础的JavaScript日期对象操作,适合初学者学习。

1789

被折叠的 条评论
为什么被折叠?



