Just do

var timeStamp = 1657756800000;
var yourDate = new Date(timeStamp);
console.log(yourDate.toISOString());

If you are still getting errors, it is likely you are passing a string to new Date(). To fix this, just do

// your timestamp as a string
var timeStamp = '1657756800000';
// parseInt() converts numbers to strings
var yourDate = new Date(parseInt(timeStamp));
console.log(yourDate.toISOString());

If you want your date formatted nicely, use toLocaleDateString and toLocaleTimeString in this function:

function printFancyTime(dateObj) {
    return dateObj.toLocaleDateString() + " " + dateObj.toLocaleTimeString();
}
// your timestamp as a string
var timeStamp = '1657756800000';
// parseInt() converts numbers to strings
var yourDate = new Date(parseInt(timeStamp));
console.log(printFancyTime(yourDate));

Answer from SteepAtticStairs on Stack Overflow
๐ŸŒ
Esqsoft
esqsoft.com โ€บ javascript_examples โ€บ date-to-epoch
Date/Epoch Time Converter - Javascript tools - Learning examples
JavaScript tool for converting date-to-epoch and/or epoch-to-date. Along with some explanation of the topic and code examples.
๐ŸŒ
MDN Web Docs
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Web โ€บ JavaScript โ€บ Reference โ€บ Global_Objects โ€บ Date โ€บ parse
Date.parse() - JavaScript | MDN
The following call, which does not specify a time zone will be set to 2019-01-01 at 00:00:00 in the local timezone of the system, because it has both date and time. js ยท Date.parse("2019-01-01T00:00:00"); Apart from the standard date time string format, the toString() and toUTCString() formats are supported: js ยท
๐ŸŒ
Epoch Converter
epochconverter.com
Epoch Converter - Unix Timestamp Converter
Online Epoch & Unix timestamp converter tools for software developers. Many converters and code examples for various programming languages.
๐ŸŒ
W3Schools
w3schools.com โ€บ js โ€บ js_date_formats.asp
W3Schools.com
If you have a valid date string, you can use the Date.parse() method to convert it to milliseconds.
๐ŸŒ
TutorialsTeacher
tutorialsteacher.com โ€บ javascript โ€บ javascript-date
JavaScript Date: Create, Convert, Compare Dates in JavaScript
var dt = new Date('2015-02-10T10:12:50.5000z'); </code></pre> <div className="card-footer example-footer"></div></div> </div> <h2>Convert Date Formats</h2> <p> Use different Date methods to convert a date from one format to another format, e.g., to Universal Time, GMT, or local time format.
๐ŸŒ
MDN Web Docs
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Web โ€บ JavaScript โ€บ Reference โ€บ Global_Objects โ€บ Date
Date - JavaScript | MDN
Converts a date to a string following the ISO 8601 Extended Format. Date.prototype.toJSON() Returns a string representing the Date using toISOString(). Intended to be implicitly called by JSON.stringify(). Date.prototype.toLocaleDateString() Returns a string with a locality sensitive representation ...
Find elsewhere
๐ŸŒ
Turing
turing.com โ€บ kb โ€บ converting-string-to-date-in-js
Learn the Basics of Converting String to Date in JavaScript
There are multiple ways to convert a string value to date in JavaScript using third-party libraries like Moment.js, Date-fns, Day.js, and Temporal.
๐ŸŒ
Timestamp Converter
timestamp-converter.com
Timestamp Converter
epoch/Unix timestamp converter into a human readable date and the other way around for developers.
๐ŸŒ
Timestamp Converter
timestamp.online
Timestamp To Date Converter
Convert timestamp to date or date to timestamp easily. Learn how to convert timestamp to date in Python, PHP, JavaScript, Bash, ...
๐ŸŒ
Codeheir
codeheir.com โ€บ blog โ€บ 2022 โ€บ 08 โ€บ 13 โ€บ date-converter-in-javascript
Date Converter in JavaScript โ€“ Codeheir
August 13, 2022 - Looking at the Mozilla docs it looks as though it takes an ISO-like format, e.g 2017-06-01T08:30. Thereโ€™s no way in JavaScript to get this format for a local date โ€” unless using moment.js (which Iโ€™m avoiding as my plan is to keep the dev utility app as light as possible).
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ javascript โ€บ convert-string-into-date-using-javascript
Convert string into date using JavaScript - GeeksforGeeks
July 11, 2025 - Using Intl.DateTimeFormat() and new Date(), the approach formats the input string using specified options for year, month, and day. It then creates a new Date object from the formatted string, effectively converting the string into a date.
๐ŸŒ
Sentry
sentry.io โ€บ sentry answers โ€บ javascript โ€บ convert unix timestamp to date and time in javascript
Convert Unix timestamp to date and time in JavaScript | Sentry
const myUnixTimestamp = 1691622800; // start with a Unix timestamp const myDate = new Date(myUnixTimestamp * 1000); // convert timestamp to milliseconds and construct Date object console.log(myDate); // will print "Thu Aug 10 2023 01:13:20" followed by the local timezone on browser console
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ how-to-convert-epoch-date-to-meaningful-javascript-date
How to convert epoch Date to meaningful JavaScript date?
August 17, 2022 - We have created the object of the date class and invoked all the above methods by taking the date object as a reference. <html> <head> </head> <body> <h2>Converting epoch date to meaningful JavaScript date.</h2> <h4>Convert milliseconds since epoch to JavaScript Date using the <i>various methods Date class.</i></h4> <p id = "output1"></p> <script> let output1 = document.getElementById("output1"); let milliseconds = 1348755654324; let myDate = new Date(milliseconds); let dateStr = myDate.getFullYear() + "/" + (myDate.getMonth() + 1) + "/" + myDate.getDate() + " " + myDate.getHours() + ":" + myDate.getMinutes() + ":" + myDate.getSeconds() output1.innerHTML += "date string for " + milliseconds + " milliseconds is : " + dateStr + " <br/> "; </script> </body> </html>
๐ŸŒ
Index.dev
index.dev โ€บ blog โ€บ convert-string-to-date-javascript
6 Simple Methods to Convert Strings to Dates in JavaScript
This blog post outlines six straightforward methods for converting a string to a date in JavaScript. Every approach possesses distinct advantages and applications: Date Constructor: Efficient and direct for ISO format. Date.parse(): Suitable for timestamps including temporal data. Moment.js: Optimal for intricate date operations.
๐ŸŒ
Vultr Docs
docs.vultr.com โ€บ javascript โ€บ examples โ€บ convert-date-to-number
JavaScript Program to Convert Date to Number | Vultr Docs
September 27, 2024 - Define a specific date by passing parameters to the Date constructor. Use getTime() to convert this date to a number.
๐ŸŒ
MDN Web Docs
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Web โ€บ JavaScript โ€บ Reference โ€บ Global_Objects โ€บ Date โ€บ toISOString
Date.prototype.toISOString() - JavaScript | MDN
const event = new Date("05 October 2011 14:48 UTC"); console.log(event.toString()); // Expected output: "Wed Oct 05 2011 16:48:00 GMT+0200 (CEST)" // Note: your timezone may vary console.log(event.toISOString()); // Expected output: "2011-10-05T14:48:00.000Z" js ยท
๐ŸŒ
Scaler
scaler.com โ€บ home โ€บ topics โ€บ convert string to date in javascript
Convert String to Date in JavaScript - Scaler Topics
January 10, 2024 - There is a class in JavaScript called the Date class. You can use this function to get the current date and time of the local system. You can also use this class's constructor to convert a date value from string data type to Date data type.