JavaScript可不可以获取时间精确到毫秒?

redwolf_123 2006-09-19 12:50:14
如题
目前可以获取精确到秒
但是不知道如何获取精确到毫秒
望高手告之
...全文
2156 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
BlueDestiny 2006-09-19
  • 打赏
  • 举报
回复
http://blog.never-online.net/article.asp?id=21
BlueDestiny 2006-09-19
  • 打赏
  • 举报
回复
<script type="text/javascript">
//<![CDATA[
var a=new Date();
var y = a.getYear()+"-";
var m = a.getMonth()+"-";
var d = a.getDay()+"-";
var h = a.getHours()+"-";
var x = a.getMinutes()+"-";
var s = a.getSeconds()+"-";
var ms=a.getMilliseconds()+"-";
document.write(y + m + d + h + x + s + ms);
//]]>
</script
redwolf_123 2006-09-19
  • 打赏
  • 举报
回复
或者别的方法 不一定要javascript
只要能在客户端获取 精确的时间就行 别的脚本也行
调用webservice也行
给点思路
redwolf_123 2006-09-19
  • 打赏
  • 举报
回复
总之越精确越好。。 不一定要毫秒
2006-9-19 13:8:25 之后能多精确一位都行
mryang9118 2006-09-19
  • 打赏
  • 举报
回复
好象不能够啊!
getDate Returns the day of the month for the specified date.
getDay Returns the day of the week for the specified date.
getHours Returns the hour in the specified date.
getMinutes Returns the minutes in the specified date.
getMonth Returns the month in the specified date.
getSeconds Returns the seconds in the specified date.
getTime Returns the numeric value corresponding to the time for the specified date.
getTimezoneOffset Returns the time-zone offset in minutes for the current locale.
getYear Returns the year in the specified date.
redwolf_123 2006-09-19
  • 打赏
  • 举报
回复
多谢,
不过我要的是获取当前的时间 有办法么?
比如获取
2006-9-19 13:8:25
但是要25后面的毫秒。。
BlueDestiny 2006-09-19
  • 打赏
  • 举报
回复
<script type="text/javascript">
<!--
var duration=2900;
var endTime = new Date().getTime() + duration + 100;
function interval()
{
var n=(endTime-new Date().getTime())/1000;
if(n<0) return;
document.getElementById("timeout").innerHTML = n.toFixed(3);
setTimeout(interval, 10);
}
window.onload=function()
{
setTimeout("window.location.href='http://blog.never-online.net'", duration);
interval();
}
//-->
</script>
<div id="timeout"></div>

87,907

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧