|
tvzml
初级用户
积分 157
发帖 67
注册 2007-5-13
状态 离线
|
『楼 主』:
[已结]同步时间服务脚本
想通过世界时间服务器同步本地计算机时间,不通过服务来实行,但是不会读取数据,高手帮忙写几句,3Q。
@echo off
wget [url]http://www.time.ac.cn/stime.asp[/url]
ren stime.asp stime.txt
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
echo %hh%:%mm%
time %hh%:%mm%
del stime.txt stime.txt 内容 下伐线部分就是 时间 的小时和分,要求取出这2个值。
Quote: | <HTML>
<HEAD>
<TITLE>国家授时中心 网络服务器时间发布</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<link rel="stylesheet" href="webclass.css" type="text/css">
</HEAD>
<BODY background="BGF.GIF" leftMargin=0 topMargin=0 MARGINWIDTH="0" MARGINHEIGHT="0" onLoad="startclock()">
<div align="center">
<p><b><font size="2" color="#9C0000">国家授时中心</font><font size="6" color="#000000"><br>
网络服务器时间发布<br>
</font><font size="5" color="#666666"> TIME OF THE NETSERVER</font></b></p>
<hr align="center" width="300" size="1" noshade color="#999999">
<table width="729" height="40" border="0" align="center" cellpadding="0" cellspacing="0">
<form action="timesearch.asp" method="Get">
<tr>
<td width="101"></td>
<td width="40"><font color="#999999" size="2"><img src="bar_left.gif" width="40" height="40"></font></td>
<td width="470"><img src="bar_main.gif" alt="时间服务" width="469" height="40" border="0" usemap="#Map"></td>
<td width="57"><img src="bar_search_text.gif" alt="站内搜索" width="56" height="40" align="absmiddle"> </td>
<td valign="middle" background="bar_bg.gif" width="79">
<input name="SearchString" type="text" class="inputtext" value="" size="10"></td>
<td valign="middle" width="33">
<INPUT name=image type="image" id="image" src="bar_search.gif" align=middle border=0></td>
</tr>
</form>
</table>
<map name="Map">
<area shape="rect" coords="15,13,79,29" href="http://www.time.ac.cn/times/timefairy.htm" target="_self" alt="NTSC 免安装 校准时间">
<area shape="rect" coords="83,14,137,29" href="http://www.time.ac.cn/serve/117.htm" target="_self" alt="NTSC 语音报时服务">
<area shape="rect" coords="146,15,202,29" href="http://www.time.ac.cn/calendar/start.htm" target="_self" alt="NTSC 农历公历对照转换">
<area shape="rect" coords="298,14,383,30" href="http://www.time.ac.cn/stime.asp" target="_self" alt="NTSC 查询世界时间">
<area shape="rect" coords="391,14,444,29" href="http://www.time.ac.cn/serve/down.htm" target="_self" alt="NTSC 时间相关软件下载">
<area shape="rect" coords="210,13,291,29" href="http://www.time.ac.cn/serve/sunriseset/" target="_blank" alt="日出日没查询">
</map>
<p><strong>
<p><b><font size="3">服务器时间:</font></b>
<script language="Javascript1.2">
<!--
document.write('<b><font face=geneva, arial, helvetica, sans-seif size=5 color=#000000>');
document.write('2008年3月30日');
document.write('</font></b>');
var tags_before_clock = "<b><font face='geneva, arial, helvetica, sans-seif' size='5' color='#000000'>";
var tags_middle_clock = "</font></b><font face='geneva, arial, helvetica, sans-seif' size='3' color='#666666'>";
var tags_after_clock = "</font>";
if(navigator.appName == "Netscape") {
document.write('<layer id="clock"></layer><br>');
}
if (navigator.appVersion.indexOf("MSIE") != -1){
document.write('<span id="clock"></span>');
}
var col = ":";
var spc = " ";
var com = ",";
var apm = "<br>";
var hrs = 22;
var min = 33;
var sec = 39;
var nowww = new Date();
var secc = sec - nowww.getSeconds();
var ff2 = 1 ;
var ff3 = 1 ;
var ff4 = 0 ;
function MakeArray(size)
{
this.length = size;
for(var i = 1; i <= size; i++)
{
this = "";
}
return this;
}
function THINPIGServerTime(){
var noww = new Date();
sec = (noww.getSeconds() + secc)%60
if(sec<0)sec=60+sec;
if(ff4==0 && (sec == 00 || sec == 60)){sec = 0;min++;ff3=1;ff4=1;}
if(sec != 00 && sec != 60)ff4=0;//使在0秒或60秒一秒钟校正多次不出现分钟增加多次的现象
if(min == 60){min=00;hrs++;ff2=1}
if(hrs == 24){hrs=0;}
if(sec==0 && min==0 && hrs==0){window.location=("stime.asp");}//新的一天的时候刷新页面主要是重新读入日期
if (hrs<=9&&ff2==1){ff2=0; hrs="0"+hrs;}
if (sec<=9) sec="0"+sec;
if (min<=9&&ff3==1) {ff3=0; min="0"+min;}
if(navigator.appName == "Netscape") {
document.clock.document.write(tags_before_clock+hrs+col+min+col+sec+apm+spc+tags_middle_clock+spc);
document.clock.document.close();
}
if (navigator.appVersion.indexOf("MSIE") != -1){
clock.innerHTML = tags_before_clock+hrs+col+min+col+sec+apm+spc+tags_middle_clock+spc;
}
}
setInterval("THINPIGServerTime()",100);//一秒钟自校对10次消除跳秒现象
//-->
</script>
<font size="3">客户机时间:</font>
<script language="JavaScript">
<!-- Hide
var timerID = null
var timerRunning = false
function stopclock(){
if(timerRunning)
clearTimeout(timerID)
timerRunning = false
}
function startclock(){
stopclock()
showtime()
}
if(navigator.appName == "Netscape") {
document.write('<layer id="clocklocal"></layer><br>');
}
if (navigator.appVersion.indexOf("MSIE") != -1){
document.write('<span id="clocklocal"></span>');
}
function stopclock (){
if(timerRunning)
clearTimeout(timerID);
timerRunning = false
}
function showtime () {
var now = new Date();
var year = now.getYear();
var month = now.getMonth() + 1;
var date = now.getDate();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds();
var timeValue = "";
timeValue += "<font size=5>"+year + "年";
timeValue += month + "月";
timeValue += date + "日"+"</font>"+tags_before_c |
|
[ Last edited by HAT on 2008-11-12 at 13:47 ]
|
|
2008-3-31 00:16 |
|
|
hhh246
初级用户
积分 74
发帖 31
注册 2006-8-26
状态 离线
|
『第
2 楼』:
@echo off
wget -N http://www.time.ac.cn/stime.asp
for /f "tokens=1,2,3,4,5 delims='年月日 " %%i in ('type stime.asp^|find "document.write('20"') do set d=%%j-%%k-%%l
date %d%
for /f "tokens=1,2,3,4 delims=; " %%i in ('type stime.asp^|find "var hrs = "') do set hh=%%l
for /f "tokens=1,2,3,4 delims=; " %%i in ('type stime.asp^|find "var min = "') do set mm=%%l
time %hh%:%mm%
|
|
2008-3-31 18:30 |
|
|
hhh246
初级用户
积分 74
发帖 31
注册 2006-8-26
状态 离线
|
|
2008-3-31 19:01 |
|
|
zh159
金牌会员
积分 3687
发帖 1467
注册 2005-8-8
状态 离线
|
『第
4 楼』:
这是一段在网上找到的系统时间自动更新JS脚本,任意Web服务器都可以用来协对时间而且也不用vb来改时间,保存为*.js点击运行即可
//get HTTP Date: response from server, return approximate dateVal object
function getServerDate(serverHttpAddress, httpProxyAddress)
{
var xmlHttp = new ActiveXObject("msxml2.xmlhttp");
if(httpProxyAddress)
{
setProxy(2,proxyHttpAddress.replace("http://",""));
}
xmlHttp.open("GET", serverHttpAddress, 0);
ts=(new Date()).getTime();
WScript.Echo("Start time: " + ts);
xmlHttp.send();
tr=new Date();
WScript.Echo("End time: " + tr.getTime());
WScript.Echo("Server Time: " + Date.parse( xmlHttp.getResponseHeader('Date')));
//Thu, 1 Jan 2009 09:47:01 GMT
tr.setTime(Date.parse( xmlHttp.getResponseHeader('Date')) + ((new Date()).getTime() - ts)/2);
//1230805540107
WScript.Echo("debug time: " + tr)
return tr;
//}
//catch(e)
//{
// return 0
//}
}
//set system time to dateString
//http://www.microsoft.com/technet/scriptcenter/topics/networking/08_atnc_advanced.mspx
//http://www.microsoft.com/technet/scriptcenter/guide/sas_wmi_fvwp.mspx?mfr=true
//20030327073509.519000+480
function setSystemDate(dateString)
{
WScript.Echo("End time: " + dateString);
var oSvc = GetObject("winmgmts:\\\\.\\root\\cimv2");
oSvc.Security_.Privileges.AddAsString("SeSystemTimePrivilege", 1);
var e = new Enumerator(oSvc.execQuery("select * from win32_OperatingSystem", "WQL", 32));
//for (;!e.atEnd();e.moveNext())e.item().SetDateTime(dateString);
}
//generating the right WMI DATETIME fields
with(getServerDate("http://www.google.com/")) //和哪一个HTTP服务器进行同步
{
setSystemDate("" +
getUTCFullYear() +
(getUTCMonth()<9?"0"+(getUTCMonth()+1):(getUTCMonth()+1)) +
(getUTCDate()<9?"0"+getUTCDate():getUTCDate()) +
(getUTCHours()<9?"0"+getUTCHours():getUTCHours()) +
(getUTCMinutes()<9?"0"+getUTCMinutes():getUTCMinutes()) +
(getUTCSeconds()<9?"0"+getUTCSeconds():getUTCSeconds()) +
".******+***");
}
|
|
|
2008-4-1 00:23 |
|
|
coolwei88
新手上路
积分 15
发帖 13
注册 2008-10-29
状态 离线
|
|
2008-11-12 11:49 |
|
|
weasel
初级用户
积分 118
发帖 66
注册 2006-8-18
状态 离线
|
|
2008-11-12 19:34 |
|
|
weasel
初级用户
积分 118
发帖 66
注册 2006-8-18
状态 离线
|
|
2008-11-12 23:23 |
|
|