programming-examples/js/Date/Write a JavaScript function to convert a Unix timestamp to time..js

10 lines
268 B
JavaScript
Raw Normal View History

2019-11-15 12:59:38 +01:00
function Unix_timestamp(t)
{
var dt = new Date(t*1000);
var hr = dt.getHours();
var m = "0" + dt.getMinutes();
var s = "0" + dt.getSeconds();
return hr+ ':' + m.substr(-2) + ':' + s.substr(-2);
}
console.log(Unix_timestamp(1412743274));