vb.net 获取互联网的北京时间
vb.net如何获取互联网的北京时间(求代码),注意是:vb.net是visualstudio2010开发的...
vb.net如何获取互联网的北京时间(求代码),注意是:vb.net
是visual studio 2010开发的 展开
是visual studio 2010开发的 展开
2个回答
展开全部
Public Function GetBeijingTime() As DateTime
Dim dt As DateTime
Dim wrt As WebRequest = Nothing
Dim wrp As WebResponse = Nothing
Try
wrt = WebRequest.Create("http://www.beijing-time.org/time.asp")
wrp = wrt.GetResponse()
Dim html As String = String.Empty
Using stream As Stream = wrp.GetResponseStream()
Using sr As New StreamReader(stream, Encoding.UTF8)
html = sr.ReadToEnd()
End Using
End Using
Dim tempArray As String() = html.Split(";"c)
For i As Integer = 0 To tempArray.Length - 1
tempArray(i) = tempArray(i).Replace(vbCr & vbLf, "")
Next
Dim year As String = tempArray(1).Split("="c)(1)
Dim month As String = tempArray(2).Split("="c)(1)
Dim day As String = tempArray(3).Split("="c)(1)
Dim hour As String = tempArray(5).Split("="c)(1)
Dim minite As String = tempArray(6).Split("="c)(1)
Dim second As String = tempArray(7).Split("="c)(1)
dt = DateTime.Parse(year & "-" & month & "-" & day & " " & hour & ":" & minite & ":" & second)
Catch generatedExceptionName As WebException
Return DateTime.Parse("2011-1-1")
Catch generatedExceptionName As Exception
Return DateTime.Parse("2011-1-1")
Finally
If wrp IsNot Nothing Then
wrp.Close()
End If
If wrt IsNot Nothing Then
wrt.Abort()
End If
End Try
Return dt
End Function
保融科技
2024-10-18 广告
2024-10-18 广告
司库管理是对企业集团以资金为主要元素的金融资源从筹集到内部配置,再到运营管理所进行的动态及全面管理,并采用信息技术手段实现,使资金管理高度契合集团发展战略。司库管理平台是在外部政策性指导以及企业集团内部自身发展诉求双重背景下产生的集团化资金...
点击进入详情页
本回答由保融科技提供
展开全部
Public Function getWebDatetime()
Dim XmlHttp As Object
XmlHttp = CreateObject("Microsoft.XMLHTTP")
XmlHttp.Open("POST", "https://www.baidu.com/", False)
XmlHttp.send()
getWebDatetime = (CDate(Date.FromOADate(1 / 3 + CDbl(CDate(Mid$(XmlHttp.getResponseHeader("Date"), 5, 21)).ToOADate()))))
XmlHttp = Nothing
End Function
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询