locked
Retrieve Server time using javascript. CRM 4 and CRM 2011 RRS feed

  • Question

  • I am working on a scenario that need to display cases' opening time ( Current time - Created time). I could use the browser's local time minus whatever the created time I got. But this wouldn't get ideal result because it's not easy to get the browser's timezone and do the math according. 

    So, I thought I could send a request to CRM Server, get the server time and then do the math. But it looks like that there is no such thing provided by CRM Web Services.

     

    Am I missing something here? 

     

     


    Monday, February 6, 2012 11:20 PM

Answers

  • Just came across this post. I think it will do the trick. I will try to confirm it.
    • Proposed as answer by D kay Monday, March 5, 2012 9:35 PM
    • Marked as answer by Wei Ma - Vancouver Tuesday, March 6, 2012 6:12 PM
    Monday, March 5, 2012 8:10 PM

All replies

  • You can write a jscript on the onload event to perform the calculation using jscript date functions. Check sample code here http://msdn.microsoft.com/en-us/library/aa239571(v=vs.60).aspx

    Dynamics CRM MVP | Inogic | http://inogic.blogspot.com| news at inogic dot com

    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"

    Tuesday, February 7, 2012 12:51 AM
  • But this is what I described as "Client Time" which depends the browsers' machine time. I would like to be able to retrieve the local time for CRM Server.
    Tuesday, February 7, 2012 12:57 AM
  • This seems to be an easy problem, yet I found no answer on the net. Should I write my own web Service to do it? Such as

    DateTime GetCurrentServerTime(){

        return DateTime.UtcNow;

    } and deploy to CRM server. So my javascript can call this web service?
    Wednesday, February 8, 2012 6:53 PM
  • Just came across this post. I think it will do the trick. I will try to confirm it.
    • Proposed as answer by D kay Monday, March 5, 2012 9:35 PM
    • Marked as answer by Wei Ma - Vancouver Tuesday, March 6, 2012 6:12 PM
    Monday, March 5, 2012 8:10 PM
  • weima.gm Thanks for sharing with us,

    Andrii , Thanks for the Solution very clever way of implementing ...

    dkay

    Monday, March 5, 2012 9:37 PM