Using AngularJS date filter with UTC date

后端 未结 10 2257
無奈伤痛
無奈伤痛 2020-11-28 07:35

I have an UTC date in milliseconds which I am passing to Angular\'s date filter for human formatting.

{{someDate | date:\'d MMMM yyyy\'}}

A

10条回答
  •  执笔经年
    2020-11-28 07:59

    Seems like AngularJS folks are working on it in version 1.3.0. All you need to do is adding : 'UTC' after the format string. Something like:

    {{someDate | date:'d MMMM yyyy' : 'UTC'}}
    

    As you can see in the docs, you can also play with it here: Plunker example

    BTW, I think there is a bug with the Z parameter, since it still show local timezone even with 'UTC'.

提交回复
热议问题