Try this:
var hms="02:04:33"; // your input string
var a = hms.split(':'); // split it at the colons
// minutes are worth 60 seconds. Hours are worth 60 minutes.
var seconds = (+a[0]) * 60 * 60 + (+a[1]) * 60 + (+a[2]);
console.log(seconds);
More Related Contents:
- How can I run different scripts based on time? [closed]
- Convert a Unix timestamp to time in JavaScript
- How to create an accurate timer in javascript?
- How do you display JavaScript datetime in 12 hour AM/PM format?
- Convert seconds to HH-MM-SS with JavaScript?
- JavaScript seconds to time string with format hh:mm:ss
- Get the time difference between two datetimes
- How to convert date to timestamp?
- Current time formatting with Javascript
- How to parse a time into a Date object from user input in JavaScript?
- Get time of specific timezone [duplicate]
- Convert time interval given in seconds into more human readable form
- How do I calculate how many seconds between two dates?
- How to read the correct time/duration values from Google Spreadsheet
- How to round time to the nearest quarter hour in JavaScript?
- Calculate Timezone offset only for one particular timezone
- How can I obtain the local time in jQuery?
- How to tell .hover() to wait?
- In JavaScript, how can I have a function run at a specific time?
- how to convert a string to a Unix timestamp in javascript?
- How do I use .toLocaleTimeString() without displaying seconds?
- Sync JS time between multiple devices
- Create a unique number with javascript time
- Converting Youtube Data API V3 video duration format to seconds in JavaScript/Node.js
- Calculate Time Difference with JavaScript
- JavaScript NTP time
- Difference between two dates in minute, hours javascript
- How to get the modified time of a file being uploaded in JavaScript?
- Does anyone know of a good JSON time server?
- Maximum Call Stack Size Exceeded During a setTimeout Call