Using AngularJS date filter with UTC date

后端 未结 10 2254
無奈伤痛
無奈伤痛 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:47

    If you do use moment.js you would use the moment().utc() function to convert a moment object to UTC. You can also handle a nice format inside the controller instead of the view by using the moment().format() function. For example:

    moment(myDate).utc().format('MM/DD/YYYY')
    

提交回复
热议问题