Best practices for DateTime serialization in .NET 3.5

前端 未结 6 1774
执念已碎
执念已碎 2020-12-01 10:45

Some 4 years back, I followed this MSDN article for DateTime usage best practices for building a .Net client on .Net 1.1 and ASMX web services (with SQL 2000 server as the b

6条回答
  •  生来不讨喜
    2020-12-01 11:39

    I think the best way of doing this is to always pass the object as UTC, and convert to local time on the clients. By doing so, there is a common reference point for all clients.

    To convert to UTC, call ToUniversalTime on the DateTime object. Then, on the clients, call ToLocalTime to get it in their current time zone.

提交回复
热议问题