Reputation: 35
I'm pretty new to Angular. I'm using Moments.js to get the difference between to times. Using duration it returns a object structured like this
Duration {_isValid: false, _milliseconds: 0, _days: 0, _months: 0, _data:
_data:
days: 0
hours: 0
milliseconds: 0
minutes: 0
months: 0
seconds: 0
years: 0
__proto__: Object
I'm trying to access the hours value and doing it by
const time = time._data.hours
It is giving me an error that _data does not exists on type Duration, however the value is showing.
How would I fix this?
Upvotes: 0
Views: 476
Reputation: 823
You dont want to use the _data object. You want to call into the function and get the value in hours...
moment.duration(2, 'hours');
https://momentjs.com/docs/#/durations/
Also momentJS is NOT affiliated with Angular.
Thanks!
Upvotes: 1