SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do you get the server DateTime in Silverlight in SharePoint 2010?

share|improve this question

To get the current local time in Silverlight (as well as in regular .NET) you can use:


To convert the DateTime to ISO 8601 DateTime format (for instance to use the DateTime value in a CAML query) you can use:


If you send a DateTime to the server in local time, the server will convert the time value into it's appropriate time zone. The best way to not have to deal with this at all is to use UTC time.

See DateTime Time zone problem for a discussion about this in relation to Silverlight.

share|improve this answer
I think you miss the word "server" in the op's question – Steve B Nov 28 '12 at 15:13
The point is you shouldn't need to have to make a service call to get the server's time. The time zones are taken care of for you in time comparisons. Or if you always use UTC (which is a good practice anyhow) you still don't need to get the time from the server. – RJ Cuthbertson Nov 28 '12 at 15:19
I agree with your point of view. But we should let the op describe it's requirement to see if it applies. – Steve B Nov 28 '12 at 15:26
Touche. The answer does not directly answer his question, but it is the right way to do this. I see both sides to that argument. – RJ Cuthbertson Nov 28 '12 at 15:30
since the silverlight is client application, the returned time is client loacal time, but each client loacal time may be difference, so in order to get consistent time, i need to get the server time. – chia_liu Nov 28 '12 at 16:23

To do this you would need to make a service call, you will receive the datatime in the returned XML. Take a look here for a starter on MSDN

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.