I am trying to parse an object by key and modify one of the fields from seconds to Hours + minutes.
tableData[key].forEach(weekday => {
mappedObject[weekday.day] = weekday.spent;
});
I've imported moment
import * as moment from 'moment';
import { Moment } from 'moment';
I've tried
tableData[key].forEach(weekday => {
mappedObject[weekday.day] = moment.duration(weekday.spent,"seconds").format("h [hrs], m [min]");
});
But I get Property 'format' does not exist on type 'Duration'.
What do i have to do to make it work ?
Forgot to mention: I am not allowed to install other external dependencies.
Try the following
let duration = moment.duration(500, "seconds");
alert(`${duration.hours()} hours ${duration.minutes()} minutes `);