JavaScript Converting milliseconds to date Last Updated : 10 Jan, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report Converting milliseconds to a date in JavaScript means transforming a millisecond timestamp (number of milliseconds since January 1, 1970, 00:00:00 UTC) into a readable date format. This is typically done using JavaScript's Date object, like new Date(milliseconds), which returns the corresponding date and time.ApproachFirst, declare variable time and store the milliseconds of the current date using the new date() for the current date and getTime() Method for returning it in milliseconds since 1 January 1970.Convert time into a date object and store it into a new variable date.Convert the date object’s contents into a string using date.toString() functionExample 1: This example first gets the milliseconds of the current date and time, Then uses that value to get the date by Date() method. JavaScript // Get the current time in milliseconds let time = new Date().getTime(); // Convert milliseconds to a Date object let date = new Date(time); console.log("Milliseconds = " + date.toString()); OutputMilliseconds = Wed Sep 18 2024 03:44:17 GMT+0000 (Coordinated Universal Time) Example 2: This example first gets the random milliseconds(1578567991011 ms), Then uses that value to get the date by Date() method. JavaScript let milliseconds = 1578567991011; // Convert milliseconds to a Date object let date = new Date(milliseconds); console.log("Milliseconds = " + date.toString()); OutputMilliseconds = Thu Jan 09 2020 11:06:31 GMT+0000 (Coordinated Universal Time) JavaScript is best known for web page development but it is also used in a variety of non-browser environments. You can learn JavaScript from the ground up by following this JavaScript Tutorial and JavaScript Examples. Comment More infoAdvertise with us Next Article JavaScript Converting milliseconds to date P PranchalKatiyar Follow Improve Article Tags : JavaScript Web Technologies javascript-date JavaScript-Questions Similar Reads How to Get Milliseconds in JavaScript? In JavaScript, you can get the current time in milliseconds, which is useful for timestamping events, measuring time intervals, and performing time calculations. JavaScript provides various methods to precisely measure time down to the millisecond, including Date.now(), performance.now(), and the Da 2 min read JavaScript Adding days in milliseconds to Date object Given a date, the task is to add days in milliseconds to it using JavaScript. To add days in milliseconds to date objects in JavaScript, some methods are used which are listed below: JavaScript getMilliseconds() Method: This method returns the milliseconds (from 0 to 999) of the provided date and ti 2 min read JavaScript Adding seconds to Date object Given a date object and the task is to add seconds to the date using JavaScript. We will use a few methods to add seconds to the date, that are discussed below: JavaScript getSeconds() Method: This method returns the Seconds(from 0 to 59) of the provided date and time. Syntax: Date.getSeconds() Para 3 min read JavaScript Program to Convert Milliseconds to Seconds Milliseconds and Seconds are important time units for planning schedules and managing daily activities and performance optimizations. Understanding this conversion helps in better time management. // Formula to convert millisecond into second: 1 millisecond = 1 / 1000 second Below are the approaches 2 min read JavaScript Date setMilliseconds() Method The date.setMilliseconds() method is used to set milliseconds into a date object which is created using the date() constructor. Syntax: dateObj.setMilliseconds(milliseconds_Value); Parameter: This method accepts a single parameter as mentioned above and described below: milliseconds_Value: This para 4 min read Like