0

There are two clients with same window application. One is in India and other one is in Belgium.
Sql server and web service application is hosted at Belgium. In sql I am storing UTC date time. Now issue is a time difference for this two clients.
I want to show UTC time in history form that mean what is stored in Database I have to bind that data to gird. No any extra code because I suppose to bind UTC date-time. Event then I get time difference for this two client. enter image description here

Blue header screen is of a Indian client and other one is of a Belgium client. In Belgium time is showing exactly as in Database but difference is for India. Am I missing anything in configuration or what?

3 Answers3

0

Ditch System.DateTime and use Noda Time!

Getting Started with Noda Time

System.DateTime uses the system culture and time zone at unpredictable moments, where Noda Time works without any defaults. Takes a bit of work to understand, but you'll never look back.

Use Noda time on the client, and store all the values in UTC in the database. You may also wish to store the original time zone that the date time was entered in.

Community
  • 1
  • 1
Paul Grimshaw
  • 19,894
  • 6
  • 40
  • 59
0

You have to convert both time zone in standard UTC and save it. Used dateadd() function to manipulate datetime. such as

declare @IST_date datetime 
declare @BE_date datetime
declare @UTC_date datetime

--Indian standard time is (GMT + 5:30 hrs)
-- Belgium standard time is ( GMT + 1 hour)

select @UTC_date = DATEADD(hh,5.30, @IST_date)
select @UTC_date = DATEADD(hh,1, @BE_date)
The Hill Boy
  • 162
  • 7
0

why not simply convert the value at display ?

DateTime MyDate = Data["ChangedDate"];
DateTime MyDateUTC = MyDate.ToUniversalTime();

tadaaaaa

Franck
  • 4,438
  • 1
  • 28
  • 55