Reputation: 62377
I have a Silverlight client that talks to some ASP.NET web services, which then modify a database. The client has data that can be modified and sent via the web services to the database. This data is organised by date.
Obviously, the client can reside in a different timezone to the ASP.NET server, so, how do I ensure that the DateTime information is in the correct timezone for the database? Will the timezone information of the DateTime survive between the client and the server such that converting to UTC will correctly result in a UTC time, or does the UTC conversion need to occur at the client?
Upvotes: 1
Views: 436
Reputation: 103397
You should use DateTime.UtcNow
in your code, then there's no question as to where the conversion is needed.
Since Silverlight runs using the .NET runtime on the client's machine, I'd assume it would get time in the user's local time zone.
You can use the TimeZoneInfo class in Silverlight to get information on the time zone the user is in. The DateTime
class itself does not store specific time zone information (just whether the time is universal or local time), so you'd need to use this to determine the user's time zone.
Upvotes: 5