Sep 18

Javascript 的时间日期处理(可以取得精确的时间,到毫秒级) 不指定

felix021 @ 2008-9-18 16:43 [IT » 网络] 评论(0) , 引用(0) , 阅读(5351) | Via 本站原创 | |
主要是对Date对象的使用。
测试一下:
<script language="javascript">
function showTime(){
var a=new Date();
var y = a.getFullYear()+"-";
var m = (a.getMonth()+1)+"-";
var d = a.getDate()+" ";
var h = a.getHours()+":";
var x = a.getMinutes()+":";
var s = a.getSeconds()+".";
var ms=a.getMilliseconds();
alert(y + m + d + h + x + s + ms);
}

//取得时间戳的办法(精确到毫秒):
function timestamp(){
  var a = new Date();
  return Date.parse(a) + a.getMilliseconds();
}
</script>




欢迎扫码关注:




转载请注明出自 ,如是转载文则注明原出处,谢谢:)
RSS订阅地址: https://www.felix021.com/blog/feed.php
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   *非必须
网址   电邮   [注册]