js获取到时间戳(兼容性强)

2022-06-30 19:59:33 浏览数 (2)

代码语言:javascript复制
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
<script>
  function thedata(d){
      return d.replace(/-/g, "/")
  }
  var serverTime = parseInt(new Date(thedata('2020-08-12 15:52:11')).valueOf());
  console.log(serverTime); // 1597218731000,获取到时间戳
</script>
</body>
</html>
1234567891011121314151617

更多内容请见原文,原文转载自:http://www.mark-to-win.com/tutorial/50901.html

0 人点赞