Search code examples
c#.netdatabase-designtimezoneapplication-design

.Net application design


We are making an application with the details below.

1) Web/Desktop App on C#.Net

2) Stores users activity timestamp as a datetime field.

We need to store this timestamp in UTC format.

Now, while displaying it will be converted to user's timezone.

Problem

The user can float from one office to another. (multiple offices all in different timezones).

Now, lets assume we want to display user's activity for one month. (It might include different timezones).

How can we store/track users timezone information?

So that it converts the time at runtime and displays proper time.

e.g.

UTC time

day1 : time1

day2: time 2

UTC +1:30

day 3: time3

etc..

Can you suggest how this issue can be dealt with.

Thanks in advance.


Solution

    1. Save all records to the database using myDate.ToUniversalTime()
    2. When loading from database using myDate.ToLocalTime()

    Then your users can move as much as they like.