how to get datetime in silverlight?

故事扮演 提交于 2019-12-11 14:13:10

问题


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:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/858469/how-to-get-datetime-in-silverlight

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!