开发者

Wrong TimeZone in DataTable

I Have a web site, which is on server1. It uses web service, which is on server2. Web service uses database, which is on server3.

Server1 server2 and server3 has different timezone, so when I get datatable via web service, Dat开发者_如何学Pythonetime type column has different time value.

For example,

if in database I have a record (date type) '2010-03-24-12:00:00', on web site I get '2010-03-24-13:00:00'

I tried to change column's "DateTimeMode" but problem was not solved.


As a rule of thumb, I have always stored datetime values in my databases as UTC and left it up to the client to adjust accordingly to its associated timezone. .NET 3.5 makes this timezone adjustment very easy.


There is a problem with serialising a DateTime and WCF.

The best solution is to always store the DateTime as UTC in the database. Then when reading the DateTime from SQL always use DateTime.Specify to specify a DateTimeKind.Utc.


Using Universal time or GMT should cure that problem.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜