js检测服务器时间与客户端是否相等
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>js检测服务器时间与客户端是否相等</title>
<script language="javascript教程">
function checkDate(time)
{
var ServiceDateTime = new Date(time.replace("-",","));
var DateTime = new Date();
var Year = 0;
var Month = 0;
var Day = 0;
//初始化时间
Year = DateTime.getFullYear();
Month = DateTime.getMonth();
Day = DateTime.getDate();
if (Year != ServiceDateTime.getFullYear())
alert("你电脑的时间与服务器的时间差一年,可能影响您的正常登陆,请设置正确的时间!");
}
</script>
</head>
<body onLoad="checkDate('2010/01/02');">
</div>
</body>
</html>
时间: 2024-10-29 21:43:03