1 回答

TA貢獻1793條經驗 獲得超6個贊
首先,我沒有得到負票。這是一個好問題。但是已經問過了。有可用的國際日期時間格式: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat
這里也解釋了:如何格式化JavaScript日期
您還可以使用toISOString(),toLocaleDateString,toDateString等。
new Date(1590486552434).toISOString();
"2020-05-26T09:49:12.434Z"
new Date(1590486552434).toLocaleDateString();
"5/26/2020"
和鏈接示例
const d = new Date('2010-08-05')
const ye = new Intl.DateTimeFormat('en', { year: 'numeric' }).format(d)
const mo = new Intl.DateTimeFormat('en', { month: 'short' }).format(d)
const da = new Intl.DateTimeFormat('en', { day: '2-digit' }).format(d)
console.log(`${da}-${mo}-${ye}`)
添加回答
舉報