Hi, I'm Samuel Cochran

on Tumblr, Google, Twitter, Facebook, LinkedIn, Flickr, GitHub, Launchpad, Stack Overflow and Xbox Live.

Wednesday, April 20th, 2011

Parse a natural duration into seconds in JavaScript

I wrote this for a little Chrome extension I maintain and thought it might be useful to someone else. It parses a natural language duration like “1h30m” or “37 days, 1 hr, 3 mins and 7s” into a straight number of seconds.