要将Unix时间戳转换为时间,您可以尝试在JavaScript中运行以下代码-
<html> <head> <title>JavaScript Dates</title> </head> <body> <script> var unix_time = 1514791901 ; var date = new Date(unix_time*1000); //上班时间 var hrs = date.getHours(); //得到分钟 var min = "0" + date.getMinutes(); //得到秒 var sec = "0" + date.getSeconds(); document.write("Time- "+hrs + ":" + min.substr(-2) + ":" + sec.substr(-2)); </script> </body> </html>
输出结果
Time- 13:01:41