【发布时间】:2021-05-20 19:21:28
【问题描述】:
我需要更改我得到的日期的格式,
例如:
2020-12-31T00:00:00
进入
2020 年 12 月 31 日
【问题讨论】:
标签: javascript ecmascript-6 ecma
我需要更改我得到的日期的格式,
例如:
2020-12-31T00:00:00
进入
2020 年 12 月 31 日
【问题讨论】:
标签: javascript ecmascript-6 ecma
let date = new Date()
let day = date.getDate()
let month = date.getMonth() + 1
let year = date.getFullYear()
if(month < 10){
console.log(`${day}/0${month}/${year}`)
}else{
console.log(`${day}/${month}/${year}`)
}
【讨论】: