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 Top answer 1 of 16
2366
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.
2 of 16
383
function timeConverter(UNIX_timestamp){
var a = new Date(UNIX_timestamp * 1000);
var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
var year = a.getFullYear();
var month = months[a.getMonth()];
var date = a.getDate();
var hour = a.getHours();
var min = a.getMinutes();
var sec = a.getSeconds();
var time = date + ' ' + month + ' ' + year + ' ' + hour + ':' + min + ':' + sec ;
return time;
}
console.log(timeConverter(0));
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date
Date - JavaScript | MDN
In essence, the timezone offset is the offset from UTC time, at the time represented by the Date object and at the location of the host environment. There are two groups of Date methods: one group gets and sets various date components by interpreting the timestamp as a local time, while the other uses UTC.
How to convert date to timestamp?
It should have been in this standard date format YYYY-MM-DD, to use below equation. You may have time along with example: 2020-04-24 16:51:56 or 2020-04-24T16:51:56+05:30. It will work fine but date format should like this YYYY-MM-DD only. var myDate = "2020-04-24"; var timestamp = +new Date(myDate) More on stackoverflow.com
Converting unix timestamp to utc date
I am working on the backend server test and I have to convert unix timestamp to utc date can anybody help? More on forum.freecodecamp.org
Date and time in JavaScript
There was a lot less cursing in that article than I expected. More on reddit.com
How can I save the values in the datepicker as the same with Firebase timestamp?
There is a from dateDate method on a Timestamp which will create a Timestamp from a javascript Date object. https://firebase.google.com/docs/reference/js/firebase.firestore.Timestamp#static-fromdate More on reddit.com
Videos
07:37
How To Convert Firestore Timestamp To JavaScript Date - YouTube
03:43
JavaScript Date From UNIX Timestamp
03:14
How to Convert Timestamp to Date Format in Javascript - YouTube
04:31
Timestamps, Date.now( ) and valueOf( ) - YouTube
01:13
JavaScript Date From UNIX Timestamp - YouTube
18:06
52. Generating and Retrieving Firestore Timestamp to auto ...
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › parse
Date.parse() - JavaScript | MDN
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 ...
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › now
Date.now() - JavaScript | MDN
// 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" }, 2000); ...
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, ...
W3Schools
w3schools.com › js › js_dates.asp
W3Schools.com
February 4, 2026 - JS Scope JS Code Blocks JS Hoisting JS Strict Mode JS Dates
date-fns
date-fns.org
date-fns - modern JavaScript date utility library
date-fns provides the most comprehensive yet simple and consistent toolset for manipulating JavaScript dates in a browser & Node.js.
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › HTML › Reference › Elements › input › date
<input type="date"> - HTML | MDN
js · const dateControl = document.querySelector('input[type="date"]'); dateControl.value = "2017-06-01"; console.log(dateControl.value); // prints "2017-06-01" console.log(dateControl.valueAsNumber); // prints 1496275200000, a JavaScript timestamp (ms) This code finds the first <input> element whose type is date, and sets its value to 2017-06-01 (June 1st, 2017).
Top answer 1 of 16
321
Split the string into its parts and provide them directly to the Date constructor:
Update:
var myDate = "26-02-2012";
myDate = myDate.split("-");
var newDate = new Date( myDate[2], myDate[1] - 1, myDate[0]);
console.log(newDate.getTime());
Updated: Also, you can use a regular expression to split the string, for example:
const dtStr = "26/02/2012";
const [d, m, y] = dtStr.split(/-|\//); // splits "26-02-2012" or "26/02/2012"
const date = new Date(y, m - 1, d);
console.log(date.getTime());
2 of 16
100
Try this function, it uses the Date.parse() method and doesn't require any custom logic:
function toTimestamp(strDate){
var datum = Date.parse(strDate);
return datum/1000;
}
alert(toTimestamp('02/13/2009 23:31:30'));
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › getTime
Date.prototype.getTime() - JavaScript | MDN
const moonLanding = new Date("July 20, 69 20:17:40 GMT+00:00"); // Milliseconds since Jan 1, 1970, 00:00:00.000 GMT console.log(moonLanding.getTime()); // Expected output: -14182940000 ... A number representing the timestamp, in milliseconds, of this date.
Coderszine
coderszine.com › convert-timestamp-to-date-using-javascript
Build Timestamp Converter to Date with JavaScript – Coderszine
Now in convert.js file, we will implement functionality to convert timestamp to date using MomentJS functions.