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// human date --> timestamp
2
3function toTimestamp(strDate){
4 var datum = Date.parse(strDate);
5 return datum/1000;
6}
7alert(toTimestamp('02/13/2009 23:31:30'));
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
1const toTimestamp=(strDate)=>{
2 var datum = Date.parse(strDate);
3 return datum/1000;
4}
5console.log(toTimestamp('02/13/2009 23:31:30'));