how to get datetime in silverlight?

2019-08-20 06:48发布

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?

2条回答
爷的心禁止访问
2楼-- · 2019-08-20 07:31

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.

查看更多
Emotional °昔
3楼-- · 2019-08-20 07:37

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.

查看更多
登录 后发表回答