Display DateTime data in TimeZone users in a DataTable

We have a reporting application in which all DateTimes are stored in UTC in a database (SQL Server 2005)

The reporting application works just to get a DataTable and bind to a DataGrid that displays information.

If we know the time zone of registered users (for example, +3 GMT), is there a way to update the dates of the DataTables that are now displayed in the user’s time zone in UTC?

We know that each column / row in a DataTable can process and do the conversion, but is there a more efficient way?

+3
source share
2 answers

, . , , , , , . , - , - :

SomeDataObject someDataObject = new SomeDataObject();

someDataObject.TimeZone = -5; //UTC Timezone for Central Standard Time
someDataObject.Time = DateTime.Now;

DateTime someTime = someDataObject.Time;
someTime.Add(someDataObject.TimeZone); // Display this back to the user
0

.NET , . TimeZoneInfo (http://msdn.microsoft.com/en-us/library/system.timezoneinfo.aspx), :

TimeZoneInfo , TimeZoneInfo . TimeZoneInfo :

  • , .
  • , .
  • .
  • , .
  • .

, .

0

Source: https://habr.com/ru/post/1708738/


All Articles