

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 Questions & Answers
- How to convert seconds to HH-MM-SS with JavaScript?
- Display seconds with SimpleDateFormat('ss') in Java
- How to convert JavaScript seconds to minutes and seconds?
- Display Seconds in ss format (01, 02) in Java
- How to convert MM/YY to YYYY-MM-DD with a specific day in MySQL?
- How to convert MM/YY to YYYY-MM-DD in MYSQL?
- Convert MySQL date format from yyyy-mm-ddThh:mm:ss.sssZ to yyyy-mm-dd hh:mm:ss ?
- Python program to convert seconds into hours, minutes and seconds
- MySQL - Convert YYYY-MM-DD to UNIX timestamp
- MySQL query to convert timediff() to seconds?
- Convert MM/DD/YY to Unix timestamp in MySQL?
- How can I convert 'HH:MM:SS ' format to seconds in JavaScript
- MySQL date format to convert dd.mm.yy to YYYY-MM-DD?
- Convert dd/mm/yyyy string to Unix timestamp in MySQL?
- Display hour with SimpleDateFormat(“hh”) in Java
Advertisements