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.
The output of the above code is...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
Code:Server 2/26/2010 5:31:50 PM Local 2/26/2010 5:31:50 PM




Reply With Quote