'Convert TimeSpan to minutes and seconds in Vue using moment

The back-end returns me a timespan in the following format as a string: 00:31:07.2764147

I need to interpretate that string and return a countdown.

Currently I am using vue 2:

  <div v-if="this.time">
  <countdown :time="this.time">
    <p>Time Remaining: {{ this.time.minutes }} minutes, {{ this.time.seconds }} seconds.</p>
  </countdown>
  </div>

data () { return { time: '00:00.00' } }

In my method I have this:

        this.time = moment(res.data.resetOtpRetriesTimestamp).format('HH:mm:ss')

Currently this returns invalid date.

I have tried to find any documentation but there is nothing there that can translate timespan to minutes and seconds and start a countdown timer which is my goal here.

I do understand that I can parse the string, I was rather looking for some easy moment function or syntax to do it.

Any ideas are welcome.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source