Results 1 to 4 of 4

Thread: [RESOLVED] Server time gets automatically converted.

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2004
    Posts
    38

    Resolved [RESOLVED] Server time gets automatically converted.

    Hi,
    I am having problem with the date time. I am getting the time from the server in xml, when i try to assign the date which i get from the server to date variable it automatically converts to local time. Is there any way to prevent this conversion.

    Code:
    Public Class Form1
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            convertDateTime("Fri Feb 26 23:01:50 +1100 2010")
            'The above date format is received from the server in xml data
            '+1100 is Australian East Daylight
        End Sub
        Private Function convertDateTime(ByVal dt As String) As DateTime
            Dim strDateTime() As String
            Dim strDay As String
            Dim strMonth As String
            Dim strDate As String
            Dim strTime As String
            Dim strYear As String
            Dim strZone As String
            Dim _dateTime As New DateTime
            Dim newTime As New DateTime
            strDateTime = Split(dt)
            strDay = strDateTime(0)
            strMonth = strDateTime(1)
            strDate = strDateTime(2)
            strTime = strDateTime(3)
            strYear = strDateTime(5)
            strZone = strDateTime(4)
            'Below Format "Sun, 09 Mar 2008 16:05:07 Zone"
            _dateTime = strDay & ", " & strDate & " " & strMonth & " " & strYear & " " & strTime & " " & strZone
            Console.WriteLine("Server " + _dateTime)
            newTime = Convert.ToDateTime(_dateTime)
            Console.WriteLine("Local " + newTime)
            Return newTime
    
        End Function
    End Class
    The output of the above code is...
    Code:
    Server 2/26/2010 5:31:50 PM
    Local 2/26/2010 5:31:50 PM
    Last edited by thatsasif; Mar 17th, 2010 at 11:11 AM.
    <===>Asif Maknojia<===>

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