1const unixTime = 1210981217;
2const date = new Date(unixTime*1000);
3console.log(date.toLocaleDateString("en-US"));
4//expected: "5/16/2008"
1var s = new Date(1504095567183).toLocaleDateString("en-US")
2// expected output "8/30/2017"
3console.log(s);
1var timestamp = 1607110465663
2var date = new Date(timestamp);
3console.log(date.getTime())
4console.log(date)
1let unix_timestamp = 1549312452
2// Create a new JavaScript Date object based on the timestamp
3// multiplied by 1000 so that the argument is in milliseconds, not seconds.
4var date = new Date(unix_timestamp * 1000);
5// Hours part from the timestamp
6var hours = date.getHours();
7// Minutes part from the timestamp
8var minutes = "0" + date.getMinutes();
9// Seconds part from the timestamp
10var seconds = "0" + date.getSeconds();
11
12// Will display time in 10:30:23 format
13var formattedTime = hours + ':' + minutes.substr(-2) + ':' + seconds.substr(-2);
14
15console.log(formattedTime);
1 javascriptCopyvar timestamp = 1607110465663
2var date = new Date(timestamp);
3
4console.log("Date: "+date.getDate()+
5 "/"+(date.getMonth()+1)+
6 "/"+date.getFullYear()+
7 " "+date.getHours()+
8 ":"+date.getMinutes()+
9 ":"+date.getSeconds());
10