- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Convert HH:MM:SS to seconds with JavaScript?
To convert the HH:MM:SS to seconds, you need to multiply the HOUR with 60X60 and Minute with 60:
Example
var time = '10:8:20'; var actualTime = time.split(':'); console.log("The time="+time); var totalSeconds = (+actualTime[0]) * 60 * 60 + (+actualTime[1]) * 60 + (+actualTime[2]); console.log("Total Seconds="+totalSeconds);
To run the above program, you need to use the following command −
node fileName.js.
Here, my file name is demo61.js.
Output
This will produce the following output −
PS C:\Users\Amit\JavaScript-code> node demo61.js The time=10:8:20 Total Seconds=36500
- Related Articles
- How can I convert 'HH:MM:SS ' format to seconds in JavaScript
- Representing seconds in HH:MM:SS in JavaScript
- How to convert a date object to string with format hh:mm:ss in JavaScript?
- How to convert JavaScript seconds to minutes and seconds?
- How to convert seconds to HH-MM-SS with JavaScript?
- Convert MySQL time from HH:MM:SS to HH:MM
- Python program to convert seconds into hours, minutes and seconds
- MySQL query to convert timediff() to seconds?
- Convert MySQL date format from yyyy-mm-ddThh:mm:ss.sssZ to yyyy-mm-dd hh:mm:ss ?
- Convert 40 minutes into seconds.
- Convert Image to Data URI with JavaScript
- How to convert time seconds to h:m:s format in Python?
- Convert 7290 seconds into hours and minutes.
- Remove Seconds/ Milliseconds from Date and convert to ISO String?
- JavaScript - convert array with null value to string

Advertisements