new Date() 获取当前时间
function() {
let aData = new Date();
console.log(aData) //Wed Aug 21 2019 10:00:58 GMT+0800 (中国标准时间)
let dateValue = aData.getFullYear() + "-" + (aData.getMonth() + 1) + "-" + aData.getDate();
console.log(this.value) //2019-8-20
}
参考地址:https://blog.youkuaiyun.com/qq_43681948/article/details/99831624
这篇博客介绍了如何在JavaScript中使用newDate()函数获取当前时间,并展示了一个示例,将日期转换为指定格式(年-月-日)。通过console.log打印了原始日期和格式化后的日期,为JavaScript日期操作提供了基础参考。
1万+

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



