【发布时间】:2017-09-15 03:44:35
【问题描述】:
我们如何将这个未格式化的日期 112889 (mmddyy) 转换为特定格式,例如 11/28/89?
console.log(new Date('112889'))
// I got this: Sat Jan 01 112889 00:00:00 GMT+0800
我在谷歌的任何地方都搜索过这个问题,但没有找到具体的答案。
参考搜索:
- https://forums.asp.net/t/1987249.aspx?How+can+i+convert+Date+1365715800000+format+to+MM+dd+yyyy
- Convert number into date using javascript
我也在考虑 momentjs 格式,但找不到任何关于此的文档,或者我只是错过了它
【问题讨论】:
-
看看 moment.js 库。 momentjs.com/docs 。时刻(“112889”,“MMDDYY”);
-
当然! @SubirKumarSao
标签: javascript angular typescript momentjs