我想在页面加载事件中使用客户端系统日期,我该怎么做呢?
由于这不是一个回复,所以请让我知道如何做。
谢谢
var a = "&date=" + (new Date().replace(/s+/g, ""));
只需将a的值附加到返回到服务器的所有链接。在服务器端,您将看到HTTP请求中出现的日期时间
var currentDate = new Date()
currentDate对象将有以下方法:
getMonth()
getDate()
getFullYear()
这应该能满足你的需要。
编辑:既然你在文章的标题中提到了时间,那么可能值得一提的是currentDate也有:
getHours()
getMinutes()
如果你想显示当前时间
编辑2:绑定到页面加载
<script type="text/javascript">
function buildDate() {
var date = new Date();
/*build date string here*/
}
</script>
<body onload="buildDate()">
Other stuff here...
</body>