Calculating date difference with angular filter

前端 未结 2 1795
心在旅途
心在旅途 2021-01-14 14:34

I needed to be able to calculate the difference between two days, inclusive, and display the difference. Ideally this would be via an angular filter so it can be used all ov

2条回答
  •  北荒
    北荒 (楼主)
    2021-01-14 15:18

    Duplicate of 26649194

    angular-moment does the trick! ...and (very) else more.

    Using the amDifference filter:

    Get the difference between two dates in milliseconds. Parameters are date, units and usePrecision. Date defaults to current date. Example:

    Difference: {{ dateFrom | amDifference : dateTo : 'days' }} days
    

提交回复
热议问题