我正在尝试将 unix 时间戳转换为可读时间。我已经尝试了所有我能找到的解决方案,但没有一个仍然有效。我不想使用任何模块或框架。我很感激转换的一些帮助。(Angular)请不要链接到其他问题。我都读了。谢谢
var unix = Math.round(+new Date()/1000);
console.log(unix) //works
function secondstotime(unix)
{
var t = new Date(1970,0,1);
t.setSeconds(unix);
var s = t.toTimeString().substr(0,8);
if(unix > 86399)
s = Math.floor((t - Date.parse("1/1/70")) / 3600000) + s.substr(2);
console.log(s);
}
secondstotime();