Results 1 to 3 of 3

Thread: Issues with date time format while downloading the web page

  1. #1

    Thread Starter
    Hyperactive Member csKanna's Avatar
    Join Date
    Dec 2005
    Location
    Tech-Tips-Now.com
    Posts
    339

    Arrow Issues with date time format while downloading the web page

    I use following code to download a web page source code in my project:

    vb Code:
    1. Private Function dlwebFile(ByVal sUrl As String, ByVal sFile As String) As Boolean
    2.     Try
    3.         Dim wr As HttpWebRequest = WebRequest.Create(sUrl)
    4.         wr.Method = "POST"
    5.         'wr.ContentLength = strPostData.Length
    6.         wr.ContentType = "application/x-www-form-urlencoded"
    7.         wr.UserAgent = "Mozilla/5.0 (Windows; U; MSIE 7.0; Windows NT 6.0; en-US)"
    8.         wr.CookieContainer = New CookieContainer
    9.  
    10.         Dim sw As StreamWriter = New StreamWriter(wr.GetRequestStream)
    11.         'sw.Write(strPostData)
    12.         sw.Close()
    13.  
    14.         Dim ws As HttpWebResponse = CType(wr.GetResponse(), HttpWebResponse)
    15.         Using str As Stream = ws.GetResponseStream()
    16.             Dim inBuf(100000000) As Byte 'allows to download upto 100 mb file
    17.             Dim bytesToRead As Integer = CInt(inBuf.Length)
    18.             Dim bytesRead As Integer = 0
    19.             While bytesToRead > 0
    20.                 Dim n As Integer = str.Read(inBuf, bytesRead, bytesToRead)
    21.                 If n = 0 Then
    22.                     Exit While
    23.                 End If
    24.                 bytesRead += n
    25.                 bytesToRead -= n
    26.             End While
    27.             Using fstr As FileStream = New FileStream(sFile, FileMode.Create)
    28.                 fstr.Write(inBuf, 0, bytesRead)
    29.             End Using
    30.         End Using
    31.         Return True
    32.     Catch ex As Exception
    33.         Return False
    34.     End Try
    35. End Function

    The web page I am trying to download is a intranet site. I am periodically downloading the web page for archiving purpose for future reference. The web page will list the current active jobs/projects we work. We process 100's of jobs everyday. The list item will have the Project id, Project name, Project deadline, etc.

    The download works fine. the web page is downloaded locally. The problem is the date/time format is changed to some other format. If I view the web page in browser, the deadline of one of the project shows as "7/15 03:00".

    However, the downloaded webpage shows the deadline of that project as "Wed Jul 14 16:30:00 CDT 2010". I believe it shows in CDT timezone. Also, it shows couple of other timezone too. I think the project might be created from those countries. I am in India timezone.

    Can someone help me on solving this issue?

    Thanks
    Kanna

  2. #2
    Hyperactive Member stepdragon's Avatar
    Join Date
    Aug 2011
    Location
    Cincinnati
    Posts
    288

    Re: Issues with date time format while downloading the web page

    Maybe this will help you out.

    If you're wrong, you'll learn. If I'm wrong, I'll learn. Try something new and go from there. That's how we improve.

    CodeBank: VB.Net - Simple Proper Image Scaling in Correct Aspect Ratio - Star Rating Control
    Useful Links: HOW TO USE CODE TAGS

  3. #3

    Thread Starter
    Hyperactive Member csKanna's Avatar
    Join Date
    Dec 2005
    Location
    Tech-Tips-Now.com
    Posts
    339

    Re: Issues with date time format while downloading the web page

    Thanks. I know how to convert from one timezone to another. I would like to stop changing the date time format conversion in first place. It is not simple to find and replace the date time format changes in html source code. The date time format is changed in tons of places.
    Kanna

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width