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);
1function timeConverter(UNIX_timestamp){
2 var a = new Date(UNIX_timestamp * 1000);
3 var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
4 var year = a.getFullYear();
5 var month = months[a.getMonth()];
6 var date = a.getDate();
7 var hour = a.getHours();
8 var min = a.getMinutes();
9 var sec = a.getSeconds();
10 var time = date + ' ' + month + ' ' + year + ' ' + hour + ':' + min + ':' + sec ;
11 return time;
12}
13console.log(timeConverter(0));