JavaScript中的日期从纪元开始需要毫秒。如果以毫秒为单位的纪元为1514789449605,则让我们将其转换为有意义的JavaScript日期。
<html> <head> <title>JavaScript Dates</title> </head> <body> <script> var val ="/Date(1514789449605)/"; var myDate = new Date( parseFloat( val.substr(6 ))); document.write("转换日期:"+ (myDate.getMonth() + 1) + "/" + myDate.getDate() + "/" + myDate.getFullYear() + " " + myDate.getHours() + ":" + myDate.getMinutes() + ":" + myDate.getSeconds() ); </script> </body> </html>
输出结果
转换日期:1/1/2018 12:20:49