views:

154

answers:

1

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?

+4  A: 

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 should be able to 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.

Dan Herbert
Thanks - I had a moment of confusion - it's all so obvious to me now. ON another point, there is one situation where I don't want conversion at all but I'm getting it from someone somewhere, any ideas on how to prevent that?
Jeff Yates