1

My application page may be long time without reloading, and user changed system date and time. And I need to know datetime from server, not from client.

  • I can insert new item to the event list, and take its Created value. But may be there clear solution? – user7268 Jun 6 '12 at 13:46
  • That would work, created by is generated by SharePoint and won't change. I guess it depends on how you need to use it. Developing a web service to do tht might be unnedded overhead/extra managed code to maintain. – Eric Alexander Jun 6 '12 at 14:38
  • Maybe you could use the JS variable _spPageContextInfo.clientServerTimeDelta but I am not sure, haven't used that before. – Marc Jan 10 '15 at 8:41
  • 1
    Have you seen sharepoint.stackexchange.com/a/130179/627 ? – eirikb Jun 15 '15 at 11:29
  • Which version of SharePoint? Different versions have different context information injected into each page. For example, in SharePoint Online Classic pages you can use _spPageContextIno.serverTime. – Rob Windsor Feb 21 at 22:29
0

You could just create a custom webservice that returns the server time and call this through JS.

  • Thank you, Steve! This is unexpected and original for me. I'll do it. – user7268 Jun 6 '12 at 13:59
  • Best thing is that it is universal way for all complex tasks. – user7268 Jun 6 '12 at 14:02
  • ashx is simpler! – Eric Dec 7 '12 at 2:06
  • There's a Stack Exchange question about it w/ JS/PHP and JS/HTML solutions for it. – Graham May 13 '15 at 19:58
  • I'm not sure the Stack Exchange question is related since it's PHP and SharePoint is ASP.NET – Steve Lineberry May 14 '15 at 11:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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