I have a winform client and wcf service that together display histori开发者_如何学JAVAcal data. the data stored in the db with utc timestamps. If two clients in different time zones want to look at a most recent day's worth of data based on their local time, can it be possible that they would be looking at different sets of data?
That depends.
- If "a day's worth" means "the last 24 hours", then they will both see the same data.
- If "a day's worth" means "00:00-23:59 of (current date - 1) in the user's local time zone", then they might see different data.
Example:
event 1 event 2 +---- service request
| | v
|---------------|---------------|- days in Central Europe
--------|-----------------|------- days in the US (Pacific time)
---------------|---------------|-- UTC day boundaries
In case 1, you just go back 24 hours from the time of the service request. It's easy to see that both customers, the one in the US and the one in Europe, will get the same list of events.
In case 2, it's more difficult: With respect to US time, events 1 and 2 happen on the same day. With respect to Europe, both events happen on different days, so the results will be different for the client in the US and the client in Europe.
Without further details the answer is both.
If a day is defined in the local time zone then changed to the UTC format before the request to the db is made they will have different data sets.
if the query is somthing like
select * from dbTable where TimeStamp >= '9/22/2010' and TimeStamp < '9/23/2010'
or
select * from dbTable where TimeStamp >= GetDate() - '24:00:00' and TimeStamp < GetDate()
then they will return the same set of data for both time zones.
It is certainly possible - it is one of the common issues with globalization/localization. The important thing to do is to convert all requests to UTC time before making the query. If the queries are all UTC-based, then the data returned to the local machines should match, as the UTC times will match.
精彩评论