以文本方式查看主题 - Foxtable(狐表) (http://www.foxtable.com/bbs/index.asp) -- 专家坐堂 (http://www.foxtable.com/bbs/list.asp?boardid=2) ---- 通过http头信息获取网络时间 (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=174636) |
-- 作者:shanshuizhujian -- 发布时间:2022/1/24 15:50:00 -- 通过http头信息获取网络时间 \'这个是帮助文件的方式,但有时候不是sql数据库的时候,无法使用,找了下面的方法。记录一下。 Public Function SDate() As Date \'Dim cmd As New SQLCommand \'cmd.C \'cmd.CommandText = "Select GetDate()" \'Return cmd.ExecuteScalar() \'通过http头获取服务器时间 Dim htc As new HttpClient("http://www.baidu.com") If htc.GetInformation() Then htc.Close() \'必须执行Close方法关闭连接 Return CDate(htc.ResponseHeaders("date")) End If End Function
|