We help IT Professionals succeed at work.
Get Started

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

IDJC
IDJC asked
on
582 Views
Last Modified: 2013-11-17
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!
Comment
Watch Question
Commented:
This problem has been solved!
Unlock 2 Answers and 2 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE