Link to home
Start Free TrialLog in
Avatar of IDJC
IDJC

asked on

Web Service changing the DateTime information even though client and server are in same TimeZone

The Web Service seems to be changing the DateTime information in a DataSet so that the client receives values with an hour difference.

I am running VS 2008, code is compiled for .NET 2.0.

I have three projects in this solution (at least that need to be considered for this question).

      Data Access Layer connecting to Oracle (Class Library) (DAL)

      Web Service connecting to Data Access Layer (Web Service) (IIS local (attaching to process aspnet_wp.exe for debug))

      .NET Compact client connecting to Web Service (Windows Application - .NET Compact) (running on USA Windows Mobile 5.0 Pocket PC R2 Emulator (set as startup project)) (Client)

I have verified the time information in the same session for both layers by using this code:

      System.Diagnostics.Debug.WriteLine("DAL/Client Current DateTime: " + DateTime.Now.ToString());
      System.Diagnostics.Debug.WriteLine("DAL/Client IsDaylightSavingTime: " + DateTime.Now.IsDaylightSavingTime());
      System.Diagnostics.Debug.WriteLine("DAL/Client TimeZone DaylightName: " + TimeZone.CurrentTimeZone.DaylightName);
      System.Diagnostics.Debug.WriteLine("DAL/Client TimeZone: " + TimeZone.CurrentTimeZone.StandardName);
      System.Diagnostics.Debug.WriteLine("DAL/Client UTC: " + DateTime.UtcNow.ToString());

Here is the output of that code:

      DAL Current DateTime: 11/10/2008 3:41:24 PM
      DAL IsDaylightSavingTime: False
      DAL TimeZone DaylightName: Mountain Daylight Time
      DAL TimeZone: Mountain Standard Time
      DAL UTC: 11/10/2008 10:41:24 PM

      Client Current DateTime: 11/10/08 3:41:09 PM
      Client IsDaylightSavingTime: False
      Client TimeZone DaylightName: Mountain Daylight Time
      Client TimeZone: Mountain Standard Time
      Client UTC: 11/10/08 10:41:09 PM

Here is the code I used in each project to generate the following debug information:

            foreach (DataRow dr in dtbl.Rows)
            {
                if (dr["the_id"].ToString() == "123456789")
                {
                    string sDebugInfo = string.Empty;
                    foreach (DataColumn dc in dtbl.Columns)
                    {
                        sDebugInfo += dc.ColumnName + ": " + dr[dc.ColumnName] + "\n";
                    }
                    Debug.WriteLine(sDebugInfo);
                }
            }

Here is the result from that:

Debugging information generated in Data Access Layer with data coming from DB:

DATE1: 10/31/2008 11:45:00 AM
DATE2: 10/31/2008 10:30:00 AM

-----

Debugging information generated in Web Service (localhost) with data coming from Data Access Layer:

DATE1: 10/31/2008 11:45:00 AM
DATE2: 10/31/2008 10:30:00 AM

-----

Debugging information generated in Client with data coming from Web Service (localhost):

DATE1: 10/31/08 10:45:00 AM
DATE2: 10/31/08 9:30:00 AM

-----

I have looked around the internet however have not had much time to research this, so I hope it has not been covered here previously and I missed it :-|

I would like to know what is going and how to fix it?

Thanks!
SOLUTION
Avatar of jose_juan
jose_juan
Flag of Spain image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial