views:

505

answers:

2

from title it appears a stupid question :) i know but i have a silverlight application that needs to send datetime to a 3rdparty web method and based on datetime populate some client side controls... now i know how to get datetime from client but problem is that client time could be wrong........ one method is to use a webservice to get datetime any other idea?

+1  A: 

Be more specific about your scenario. What do you mean by 'client time could be wrong'?

If you mean that client time could be different than server time because of world time difference (e.g. client accessed from USA while server is in UK) than you have to make sure to convert your time to Universal Time by calling DateTime.ToUniversalTime() before sending it.

jarek
no! i mean what if the clock on client's machine is not set properly and is displaying wrong values... like i could tweek with my clock and silverlight will surely reads values from my clock
Usman Masood
then get UTC time from a server and translate it to local time on the client time usig .ToLocalTime().I still don't get your scenario, but I'd think that it is safe to assume that client's time is the right time in most cases anyway.
jarek
+2  A: 

If you need the reliability of the server's time, then yeah -- a web service would suffice. I ran into a limitation with Silverlight recently that only a web service (WCF or otherwise) would solve. I chose an ordinary .NET web service for my scenario and when it was all said and done it worked like a charm.

Steve Wortham
i agreed, this is only solution
Usman Masood