I’m working on a project where the user needs to provide time estimates on specific tasks. Im wondering if there’s a script already out there ( like date.js ) that can take user input and parse it to number of seconds.
Examples:
"2 days" = 172800
"2 hours" = 7200
"1d 5h" = 104400
"15 minutes" = 900
date.js is great for finding the specific date in the future, but I need the total number of seconds, not a specific end date.
I will code this myself if it doesn’t already exist, just want to save some time if it’s out there.
Here’s a library off the top of my head (sorry I couldn’t resist)
Try it out: http://jsbin.com/ozeda/2/edit