Prefix it with a date:

var hms = "01:12:33";
var target = new Date("1970-01-01T" + hms);
console.log(target);

There target.getTime() will give you the number of milliseconds since the start of the day;

Or, if you need it to be today's date:

var now = new Date();
var nowDateTime = now.toISOString();
var nowDate = nowDateTime.split('T')[0];
var hms = '01:12:33';
var target = new Date(nowDate + 'T' + hms);
console.log(target);

There target.getTime() will give you the number of milliseconds since the epoch.

Answer from cwallenpoole on Stack Overflow
๐ŸŒ
Esqsoft
esqsoft.com โ€บ javascript_examples โ€บ date-to-epoch
Date/Epoch Time Converter - Javascript tools - Learning examples
First off, the easiest way to get the current time in epoch (using JavaScript), is to call getTime() method of the JavaScript Date object and divide the return value by 1000. getTime returns the number of milliseconds elapsed, in your computer's timezone, since 1/1/1970 GMT.
Discussions

Conversion from timestamp to time in JavaScript - Stack Overflow
My problem is that I am receiving a timestamp from another app. When I convert the timestamp to time the time that gets returned is always wrong This is the JavaScript code: var time = new Date(tim... More on stackoverflow.com
๐ŸŒ stackoverflow.com
date - Convert a Unix timestamp to time in JavaScript - Stack Overflow
I am storing time in a MySQL database as a Unix timestamp and that gets sent to some JavaScript code. How would I get just the time out of it? For example, in HH/MM/SS format. More on stackoverflow.com
๐ŸŒ stackoverflow.com
javascript - Convert UTC date time to local date time - Stack Overflow
From the server I get a datetime variable in this format: 6/29/2011 4:52:48 PM and it is in UTC time. I want to convert it to the current userโ€™s browser time zone using JavaScript. How this can be ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
Convert date to another timezone in JavaScript - Stack Overflow
Stolen shamelessly from: http://www.techrepublic.com/article/convert-the-local-time-to-another-time-zone-with-this-javascript/6016329 More on stackoverflow.com
๐ŸŒ stackoverflow.com
๐ŸŒ
W3Schools
w3schools.com โ€บ jsref โ€บ jsref_totimestring.asp
JavaScript Date toTimeString() Method
The toTimeString() method returns the time portion of a date object as a string. toTimeString() is an ECMAScript1 (JavaScript 1997) feature.
๐ŸŒ
W3Resource
w3resource.com โ€บ javascript-exercises โ€บ javascript-basic-exercise-51.php
JavaScript basic: Convert a given number to hours and minutes - w3resource
July 1, 2025 - This JavaScript application converts a given numerical value representing minutes into hours and minutes. It calculates the hours by dividing the total minutes by 60 and the remaining minutes using the modulus operator, then formats and displays ...
๐ŸŒ
Epochconverter
epochconverter.io โ€บ blogs โ€บ javascript-timestamp-conversions
Ultimate Guide to Timestamp Conversions in JavaScript: Best Practices and Tips
1 2 3 4 5 6 7 8 9const dateString = "March 11, 2023 4:36:01 PM"; const timestamp1 = Date.parse(dateString); const date = new Date(dateString); const timestamp2 = date.getTime(); const timestamp3 = Date.UTC(2023, 2, 11, 16, 36, 1); console.log(timestamp1); // 1647022561000 console.log(timestamp2); // 1647022561000 console.log(timestamp3); // 1647022561000JavaScript provides several methods for converting timestamps between different formats. Here are the most common types of timestamp conversions in JavaScript with examples:
๐ŸŒ
Epoch Converter
epochconverter.com
Epoch Converter - Unix Timestamp Converter
The full list in the programming ... for converting human-readable dates to epoch time. ... Thanks to everyone who sent me corrections and updates! More date-related programming examples: What's the current week number? - What's the current day number? Please note: All tools on this page are based on the date & time settings of your computer and use JavaScript to convert ...
๐ŸŒ
DEV Community
dev.to โ€บ kecbm โ€บ time-conversion-383d
Time conversion - DEV Community
March 5, 2024 - So let's check if the time string has PM in its structure ... The includes method will return true if the value is contained in the string and false if the value is not contained in the string ยท If the hour string has the PM we will convert the format from 12 hours to 24 hours as follows:
Find elsewhere
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ javascript โ€บ javascript-program-to-convert-string-to-24-hour-time-format
JavaScript Program to Convert String to 24-hour Time Format - GeeksforGeeks
July 23, 2025 - We can leverage its functionality to easily convert a string to 24-hour time format. First, you need to include the Moment.js library in your project. You can do this by either downloading the library and adding it to your project or using a package manager like npm to install it. Once Moment.js is included in your project, you can use its parsing and formatting capabilities to convert the input string to 24-hour time format.
๐ŸŒ
Wikiversity
en.wikiversity.org โ€บ wiki โ€บ JavaScript โ€บ Epoch_time_converter
JavaScript/Epoch time converter - Wikiversity
December 3, 2022 - --> <div id="button_container" style="display:inline-block; margin-bottom:0;"> <!-- keeping the buttons in one row --> <button class="run_script" onclick="epoch.convert(); document.location.hash=time_input.value;"> Auto-detect and convert </button> <!-- interchanges the date and time with the epoch time stamp --> <button class="epoch_swap" onclick="epoch.swap();">Swap</button> <!-- sets the input to the current date and time --> <button class="epoch_now" onclick="epoch.now();">Now</button> <!-- more convenient clearing of the input field, mainly for mobile users --> <button class="epoch_clear"
๐ŸŒ
Medium
mlarcher531.medium.com โ€บ time-conversion-algorithm-in-javascript-7b8597f51881
Time Conversion Algorithm in Javascript | by Mike Archer | Medium
December 29, 2021 - Note: โ€” 12:00:00AM on a 12-hour clock is 00:00:00 on a 24-hour clock. - 12:00:00PM on a 12-hour clock is 12:00:00 on a 24-hour clock. Complete the timeConversion function in the editor below. Itโ€ฆ
๐ŸŒ
Epochconvert
epochconvert.com โ€บ programming โ€บ javascript
Date Time Conversion in JavaScript - Epoch Converter
We can get current epoch or unix timestamp in JavaScript using Date() objects and getDate() function. var date = new Date(); var timestamp = date.getTime(); The getTime() function returns timestamp in milliseconds. We can get current unix timestamp in seconds using below code. var date = new ...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ javascript โ€บ how-to-convert-unix-timestamp-to-time-in-javascript
How to convert Unix timestamp to time in JavaScript ? - GeeksforGeeks
July 12, 2025 - function convertTimestamptoTime() { let unixTimestamp = 10637282; // Convert to milliseconds and // then create a new Date object let dateObj = new Date(unixTimestamp * 1000); let utcString = dateObj.toUTCString(); let time = utcString.slice(-11, ...
๐ŸŒ
SheCodes
shecodes.io โ€บ athena โ€บ 1363-how-to-convert-a-timestamp-to-hours-in-javascript
[JavaScript] - How to Convert a Timestamp to Hours in | SheCodes
Learn how to convert a timestamp to hours in JavaScript using the getHours() method from the Date object. Quick and easy example included.
๐ŸŒ
Zipy
zipy.ai โ€บ blog โ€บ convert-unix-timestamp-to-date-and-time-in-javascript
convert unix timestamp to date and time in javascript
April 12, 2024 - To convert a Unix timestamp to a date and time, you can use the Date constructor, passing the timestamp multiplied by 1000 (to convert seconds to milliseconds, as JavaScript deals with time in milliseconds).