let unix_timestamp = 1549312452;

// Create a new JavaScript Date object based on the timestamp
// multiplied by 1000 so that the argument is in milliseconds, not seconds
var date = new Date(unix_timestamp * 1000);

// Hours part from the timestamp
var hours = date.getHours();

// Minutes part from the timestamp
var minutes = "0" + date.getMinutes();

// Seconds part from the timestamp
var seconds = "0" + date.getSeconds();

// Will display time in 10:30:23 format
var formattedTime = hours + ':' + minutes.substr(-2) + ':' + seconds.substr(-2);

console.log(formattedTime);

For more information regarding the Date object, please refer to MDN or the ECMAScript 5 specification.

Answer from Aron Rotteveel on Stack Overflow
🌐
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
To convert these into human-readable dates and times, we can use JavaScript’s Date object. This object’s constructor takes a value similar to a Unix timestamp, but in milliseconds rather than seconds.
Discussions

How to convert date to timestamp? - javascript
Simply performing some arithmetic ... the timestamp as a number. This is useful for compact notation. I find this is the easiest way to remember, as the method also works for converting numbers cast as string types back to number types. ... This would do the trick if you need to add time also new ... More on stackoverflow.com
🌐 stackoverflow.com
node.js - Function to convert timestamp to human date in javascript - Stack Overflow
How to convert this timestamp 1382086394000 to 2013-10-18 08:53:14 using a function in javascript? Currently I have this function: function cleanDate(d) {return new Date(+d.replace(/\/Date\((\d+)\)\//, '$1'));} ... Besides all the answers here, the de facto standard in js date/time handling ... More on stackoverflow.com
🌐 stackoverflow.com
How can I convert "2020-11-18-05:12" into unix timestamp? and then add 5 hours to it?
Prerequisite: dealing with dates and times in programming is one of the most non-trivial things you can ever undertake. Until the JS standard library can handle date-time in a sane manner, seriously consider using a library like Luxon instead of trying to wrangle time on your own! You should generally allow the browser to calculate the local time, instead of changing the timestamp. Let's break down why. First, to get the ms from epoch: const dateTimeString = '2020-11-18-05:12' const [years, months, days, hours, minutes, seconds = 0, ms = 0] = dateTimeString.split(/[-:]/).map(n => +n) const unixDate = new Date(years, months - 1, days, hours, minutes, seconds, ms).valueOf() If you take that number, add 18,000,000 to it (5hrs in ms), then pass that number back into the Date constructor, you will find that the time is now wrong by 5 hours. This is because the Date constructor assumes all dates are entered in UTC, and will automatically use the timezone of the local machine to display the appropriate time (assuming that is what you are trying to accomplish). Also assuming that all you want is to display that time string in the user's local time, just remove the .valueOf() and you have a timezone appropriate Date object. As an aside, that string is almost an ISO 8601-1:2019 compliant date-time string, 2020-11-18T05:12:00, which can be converted directly with the Date constructor. Edit: A better way to offset the time, is to use a date-time+timezone string: const dateTimeString = '2020-11-18-05:12' const offset = '+05:00' const [years, months, days, hours, minutes, seconds = '00', ms = '000'] = dateTimeString.split(/[-:]/) const date = new Date(`${years}-${months}-${days}T${hours}:${minutes}:${seconds}.${ms}${offset}`) More on reddit.com
🌐 r/learnjavascript
4
1
November 18, 2020
Any way to see the exact time a message was sent/received?

You can derive the exact timestamp from any message by using its ID.

You can get the ID of a message by enabling Developer Mode in User Settings > Advanced, then right clicking any message (or user, or channel) to copy the ID to your clipboard

I made a simple page that converts this snowflake ID into a timestamp: https://snowsta.mp

More on reddit.com
🌐 r/discordapp
7
7
August 12, 2015
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date
Date - JavaScript | MDN - Mozilla
A JavaScript date is fundamentally specified as the time in milliseconds that has elapsed since the epoch, which is defined as the midnight at the beginning of January 1, 1970, UTC (equivalent to the UNIX epoch). This timestamp is timezone-agnostic and uniquely defines an instant in history.
🌐
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 - For more complex formatting needs or to handle multiple locales and time zones, you might consider using a library like moment.js or date-fns. These libraries offer extensive functionalities for date and time manipulation, including straightforward Unix timestamp conversions.
🌐
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 - Convert the UNIX timestamp to milliseconds. Create a Date object. Use Intl.DateTimeFormat to format the time in the desired locale and options.
🌐
Toptal
toptal.com › software › definitive-guide-to-datetime-manipulation
How to get the Timestamp And Date in Javascript: JS DateTime | Toptal®
December 2, 2020 - This makes JavaScript date-from-timestamp and JavaScript timestamp-to-date conversion straightforward, provided the UTC time zone is used.
Find elsewhere
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › parse
Date.parse() - JavaScript | MDN - Mozilla
The Date.parse() static method parses a string representation of a date, and returns the date's timestamp. // Standard date-time string format const unixTimeZero = Date.parse("1970-01-01T00:00:00Z"); // Non-standard format resembling toUTCString() const javaScriptRelease = Date.parse("04 Dec 1995 00:12:00 GMT"); console.log(unixTimeZero); // Expected output: 0 console.log(javaScriptRelease); // Expected output: 818035920000
🌐
Timestamp Converter
timestamp.online › article › how-to-convert-timestamp-to-datetime-in-javascript
How To Convert Timestamp To Date and Time in JavaScript - Code Example
They are: toDateString · Converts the date portion of a Date object into a readable string · toGMTString · Deprecated. Use the toUTCString() method instead · toISOString · Returns the date as a string, using the ISO standard · toJSON · Returns the date as a string, formatted as a JSON date ·
🌐
W3Resource
w3resource.com › javascript-exercises › javascript-date-exercise-17.php
JavaScript: Convert a Unix timestamp to time - w3resource
July 17, 2025 - // Define a JavaScript function ... { // Create a new Date object representing the UNIX timestamp multiplied by 1000 (to convert seconds to milliseconds) and store it in the variable dt var dt = new Date(t*1000); // Extract ...
🌐
CoreUI
coreui.io › answers › how-to-convert-a-timestamp-to-a-date-in-javascript
How to convert a timestamp to a date in JavaScript · CoreUI
October 2, 2025 - Convert a timestamp to a date in JavaScript using new Date() constructor with timestamp parameter for accurate date object creation.
🌐
Codedamn
codedamn.com › news › javascript
How to convert timestamp to date in JavaScript?
November 3, 2022 - Convert a timestamp to a valid date object using moment.js.
🌐
Day.js
day.js.org › docs › en › parse › unix-timestamp
Unix Timestamp (seconds) · Day.js
Create a Day.js object from a Unix timestamp (10 digits, seconds since the Unix Epoch).
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › now
Date.now() - JavaScript - MDN Web Docs - Mozilla
// This example takes 2 seconds to run const start = Date.now(); console.log("starting timer..."); // Expected output: "starting timer..." setTimeout(() => { const ms = Date.now() - start; console.log(`seconds elapsed = ${Math.floor(ms / 1000)}`); // Expected output: "seconds elapsed = 2" }, ...
🌐
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.
🌐
Squash
squash.io › how-to-convert-a-unix-timestamp-to-time-in-javascript
How to Convert a Unix Timestamp to Time in Javascript
December 7, 2023 - If you have a Unix timestamp in milliseconds, divide it by 1000 to convert it to seconds before performing the conversion. 2. If you need to perform multiple conversions or formatting operations, consider creating a helper function to encapsulate the logic. This can improve code readability and reusability. 3. Be aware of the limitations of date and time formatting in different locales.
🌐
Delft Stack
delftstack.com › home › howto › javascript › javascript convert timestamp to date
How to Convert Unix Timestamp to Date in JavaScript | Delft Stack
February 12, 2024 - In this example, the timestamp variable holds a Unix timestamp (in milliseconds) that corresponds to December 4, 2020, 19:34:25.663 UTC. By creating a new Date object with this timestamp, we are effectively converting the timestamp value into a human-readable date and time representation.
🌐
Scaler
scaler.com › home › topics › convert timestamp to date in javascript
Convert Timestamp to Date in JavaScript - Scaler Topics
October 13, 2022 - However, JavaScript has multiple functions to present date and time in a way that humans can understand. By using the Date() object and its methods in JavaScript the UNIX timestamps can be converted to the required date and time formats.