按键精灵 获取某网站服务器时间,按键精灵如何获得网络时间的毫秒

本文将介绍如何利用现有代码片段,将电脑本地时间的毫秒获取方式转换为获取网络时间的毫秒,涉及API调用、XMLHttpRequest和日期解析技巧。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

获取电脑时间毫秒写法一:timer

t = timer

MsgBox t & vbcrlf & "现在时间是 " & Second2HNM(t)

Function Second2HNM(ABC)

Decimal = ABC - Int(ABC)

CK = ""

If Not ABC\60\60\24=0 Then CK = CK & (ABC\60\60\24)&"天"

If Not (ABC\60\60 mod 24)=0 Then CK = CK & (ABC\60\60 mod 24)&"小时"

If Not (ABC\60 Mod 60)=0 Then CK = CK & (ABC\60 Mod 60)&"分"

If Not (ABC mod 60)=0 Then CK = CK & (ABC mod 60)+Decimal & "秒"

Second2HNM = CK

End Function

获取电脑时间毫秒写法二:now、timer

t = timer

MilliSec= Round((t - Int(t))*1000,0)

MsgBox Now & ":" & MilliSec

获取电脑时间毫秒写法三:API

Private Declare Sub GetLocalTime Lib "kernel32" (lpSystemTime As SYSTEMTIME)

lpSystemTime = "00000000"

GetLocalTime lpSystemTime

MessageBox Now & ":" & AscW(Right(lpSystemTime,1))

获取网络时间秒的写法

dim http,sdate

Set http = createobject("msxml2.XMLHTTP")

http.open "HEAD", "http://www.baidu.com"

http.send

sdate=http.getresponseheader("Date")

sdate = dateadd("h", 8, cdate(mid(sdate, 5, len(sdate) - 8)))

Set http = nothing

如何利用上述资源,把获取电脑时间毫秒改为获取网络时间毫秒

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值