title: How to get online date in vb.net?
body: <blockquote>
    <p>How to get online date in vb.net ? is this possible ?</p>
    
    <p>i use this code but it gives error like this (The remote server
    returned an error: (503) Server Unavailable.) can anyone help ? thank you in advance</p>
  </blockquote>
  
  <pre><code>Imports System.ComponentModel
  
  Public Class Form1
  
      Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  
      End Sub
      Private Function getPageSource(ByVal URL As String) As String
          Dim getWebClient As System.Net.WebClient = New System.Net.WebClient()
          Dim strSource As String = getWebClient.DownloadString(URL)
          getWebClient.Dispose()
          Return strSource
      End Function
  
      Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
          Dim myPageSource, myStr, myStr1, strDate As String
          Dim curLen, myStrPos, setStartPos As Integer
          Dim dt As DateTime
  
          txtPageSource.Text = getPageSource("http://www.worldtimeserver.com/current_time_in_PH.aspx")
          myPageSource = txtPageSource.Text
  
          'code to trim all the text till TIME start position
          myStr = ""
          myStrPos = myPageSource.IndexOf(myStr)
          txtPageSource.Text = txtPageSource.Text.Remove(1, myStrPos + 23)
          myPageSource = txtPageSource.Text
  
          'code to trim all the text till after DATE
          curLen = Len(txtPageSource.Text)
          myStr1 = "2010"
          setStartPos = myPageSource.IndexOf(myStr1)
          txtPageSource.Text = txtPageSource.Text.Remove(setStartPos + 4, curLen - setStartPos - 4)
  
          'code to trim "" and "" tags in between TIME and DATE
          ' 6:27 AM
          ' 
          '
          'Wednesday, June 23, 2010
          txtPageSource.Text = txtPageSource.Text.Replace("", "")
          txtPageSource.Text = txtPageSource.Text.Replace("", "")
  
          strDate = txtPageSource.Text
          dt = CType((TypeDescriptor.GetConverter(New DateTime(2000, 1, 1)).ConvertFrom(strDate)), DateTime)
          'txtPageSource.Text = dt
          MsgBox(dt)
      End Sub
  
  End Class
  </code></pre>