Skip to content

Latest commit

 

History

History
79 lines (67 loc) · 2.72 KB

tools.md

File metadata and controls

79 lines (67 loc) · 2.72 KB
layout title
tools
Tools

时间戳

Unix Timestamp 是一种时间表示方式,定义为从格林威治时间1970年01月01日00时00分00秒起至现在的总秒数,不仅在Unix类系统中使用,在许多其它操作系统中也被广泛采用。

时间戳 毫秒(ms) 秒(s) 转换 北京时间

时间 北京时间 转换 秒(s) 毫秒(ms)

当前时间戳(Unix Timestamp):

<script type="text/javascript"> var getDate = function(ts) { var d = new Date(ts); }; var curr = new Date().getTime(); var timer = setInterval(function() { document.getElementById("text_current_timestamp").value=new Date().getTime(); }, 1000); document.getElementById("text_current_timestamp").value=curr; document.getElementById("input_timestamp").value=new Date().getTime(); function test(){ var output = document.getElementById("output_timestamp"); var unit = document.getElementById("input_timestamp_unit").value; var input = parseInt(document.getElementById("input_timestamp").value); if (unit == "s") { input = input * 1000; } var value = new Date(input); ////console.log(jutils.formatDate(new Date(1600187681111),"YYYY-MM-DD HH:ii:ss")); output.value = value.toISOString(); //console.log(value.toString()); //console.log(value.toUTCString()); //console.log(value.toISOString()); //console.log(value.toGMTString()); //console.log(value.toDateString()); //console.log(value.toTimeString()); } </script>

通过 new Date().getTime() 获取时间戳,单位是毫秒。

xxxxxx