gpt4 book ai didi

javascript - moment.js IN ember 无法在 IE 中工作

转载 作者:行者123 更新时间:2023-12-01 03:41:35 24 4
gpt4 key购买 nike

我必须将当前日期和时间添加到我的 UI 中。我已在我的应用程序 moment.js 中安装了 ember 插件,但它可以在 chrome 中运行,但在 IE 中显示无效日期。

我在我的模型中添加了时刻代码-

Date: function() {
return moment(new Date(parseFloat(this.get('createOn'))).toLocaleString()).format('MMM Do YYYY, h:mm:ss a');
}.property('createOn')

任何使其在 IE 中也能工作的解决方案。

最佳答案

不同浏览器(尤其是 IE)的日期解析是不同的。

请使用 moment.js 规范您的解析:

return moment('X', this.get('createOn')).format('MMM Do YYYY, h:mm:ss a');

参见here更多解析和格式化选项。

关于javascript - moment.js IN ember 无法在 IE 中工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43833807/

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