Search code examples
javascriptmomentjsdatetime-conversion

How to use moment js to convert "hh:mm:ss" time format into hours, minutes, seconds?


For example, I have a time string in the form "00:30:00", so the output should be 30 minutes. Or if we have "15:00:30", so the output should be 15 hours 30 seconds. Can it be done using moment? or do I need to write my own code?


Solution

  • Here is a post that can help you: https://stackoverflow.com/a/21840646/4573534

    All you need to do now is to parse hh:mm:ss to milliseconds