gpt4 book ai didi

javascript - 日期时间、日期和月份错误

转载 作者:行者123 更新时间:2023-12-02 22:42:16 27 4
gpt4 key购买 nike

我正在使用此函数来获取当前日期时间。

问题是月份和日期错误。我可能做错了什么?

是否还有一种方法可以在天和小时之间给出间隔?

例如:2019年10月24日18:50:12:02

setInterval(() => {
this.date = new Date().getDay() + '/' + new Date().getMonth() + '/' + new Date().getFullYear() + '' + new Date().getHours() + ':' + new Date().getMinutes() + ':'+ new Date☮.getSeconds()
}, 1);

最佳答案

就像 @insertusernamehere 所说:getDay 返回星期几,getMonth 从 0 开始。

获取2019年10月24日18:50:12:02 | 日/月/年时:分:秒:毫秒以下作品

date = `${d.getDate()}/${d.getMonth()+1}/${d.getFullYear()} ${d.getHours()}:${d.getMinutes()}:${d.getSeconds()}:${d.getMilliseconds()}`;

返回:“24/10/2019 13:13:11:308”

关于javascript - 日期时间、日期和月份错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58546832/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com