如何把
转为成这样的日期格式
转换其他格式还有什么样的操作??
不用moon.js就是最传统的转换操作JS应该怎么实现?
如何把
哈喽,可以将各个时段取出来再进行拼接,代码如下:
const date = new Date()
const year = date.getFullYear()
const month = date.getMonth() + 1
const day = date.getDate()
const hour = date.getHours()
const minute = date.getMinutes()
const str = `${year}-${month}-${day} ${hour}:${minute}`
console.log(str);