【问题标题】:Time is not formatting correctly时间格式不正确
【发布时间】:2015-10-15 16:35:04
【问题描述】:

我有这个日期

    <p am-time-ago="Thu Oct 15 21:53:55 IST 2015"></p>

它显示 [$parse:syntax] Syntax Error: Token 'Oct' is an unexpected token at column 5 of the expression [Thu Oct 15 21:53:55 IST 2015] starting at [Oct 15 21:53:55 IST 2015].

2015-10-13T18:49:52.888Z

它显示Token 'T18' is an unexpected token at column 11 of the expression [2015-10-13T18:49:52.888Z] starting at [T18:49:52.888Z].

【问题讨论】:

    标签: momentjs angular-moment


    【解决方案1】:

    Moment 无法正确解析日期,因为它的格式不受支持。

    对于第一个,将 IST 更改为偏移量 (+05:30)。

    第二个,去掉T和Z,在日期和时间之间放一个空格。

    编辑:请注意,moment js 的最新版本不再支持 TZ 缩写,例如 IST、CST 或 UTC。该功能在 1.6.0 中已弃用。

    【讨论】:

    • 我认为这是moment.js中的一种错误,因为timeago插件解析2015-10-13T18:49:52.888Z格式
    • 有可能,前者是由于(相对)最近对不推荐使用 TZ 缩写格式(例如 IST、CST)的解析器所做的更改。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多