Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including hms-parse with all npm packages installed. Try it out:

var hmsParse = require("hms-parse")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

hms-parse v1.0.0

Parse hms time strings to and from seconds

hms-parse npm downloads tests maintained

Parse hms time strings to and from seconds


npm install --save hms-parse


const hms = require('hms-parse')

let seconds
seconds = hms.toSeconds(['1h', '45m', '10s']) // => 6310
seconds = hms.toSeconds(['45m', '10s']) // => 2710
seconds = hms.toSeconds(['10s']) // => 10
seconds = hms.toSeconds(['1s', '5S', '10m', '4M', '3h', '1H']) // => 15246

let timeString
timeString = hms.fromSeconds(6310) // => '1:45:10'
timeString = hms.fromSeconds(2710) // => '45:10'
timeString = hms.fromSeconds(10) // => '10s'
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free