vb.net获取北京时间的简单介绍

vb.net 获取互联网的北京时间

Public Function GetBeijingTime() As DateTime

公司主营业务:成都做网站、网站制作、成都外贸网站建设、移动网站开发等业务。帮助企业客户真正实现互联网宣传,提高企业的竞争能力。创新互联是一支青春激扬、勤奋敬业、活力青春激扬、勤奋敬业、活力澎湃、和谐高效的团队。公司秉承以“开放、自由、严谨、自律”为核心的企业文化,感谢他们对我们的高要求,感谢他们从不同领域给我们带来的挑战,让我们激情的团队有机会用头脑与智慧不断的给客户带来惊喜。创新互联推出藤县免费做网站回馈大家。

Dim dt As DateTime

Dim wrt As WebRequest = Nothing

Dim wrp As WebResponse = Nothing

Try

wrt = WebRequest.Create("")

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

如何用VB获取北京时间

now() 可以获取当前的时间。

可以使用 print now() 进行测试。输出当前时间。

想用文本保存。

那就:

open app.path "\time.txt" for output as #1

print #1,now()

close

用VB怎么获取标准北京时间啊??

可以获取中国科学院国家授时中心的标准时间(即中国北京时间)。

你可以借用vb的inet控件从中科院的网站上获取,中科院网站是:

vb怎么获取系统当前的系统时间啊

vb中获取系统当前的时间用函数 now() 就可以。另外还有相关的时间 date() time()

now()获取系统当前日期和时间,如:2015-12-12 22:23:34

time()获取系统的时间,如:22:23:34不显示当前日期

date()获得系统的日期,如:2015-12-12

Private Sub Command1_Click()

MsgBox Now()

MsgBox Time()

MsgBox Date

End Sub

vb怎么获取北京时间

VB里有好多时间函数,使用方法和excel类似,直接调用就好了,比如now显示当前时间,today表示当前日期,又如year年,month月,day日,hour小时(24小时制),minute分,second秒;

另外要想获得想要的时间格式,你需要一个格式函数Formart(),表示为formart(date,formart of date),比如我想获得今天的日期并且用这种格式2015-08-31,那么函数是formart(now,"ddddd"),这里的ddddd就是格式符,想要获得全部的格式符可以百度“formart()函数使用“,我这里就不引用了,希望以上内容对你有帮助


文章题目:vb.net获取北京时间的简单介绍
当前网址:http://myzitong.com/article/hchsjh.html