title: How to tick based on external time in C#?
body: <p>There is this API that when called gives me the time of a remote server. This is the response JSON of that API:</p>
  
  <pre><code>{
      hour: 12,
      minute: 2,
      second: 20,
      msFormat: "/Date(1590478340707)/"
  }
  </code></pre>
  
  <p>This time is not in sync with the server my code runs on. And I need milliseconds precision for my code according to time of the remote server.</p>
  
  <p>I want to call another API of that server, exactly based on some time relative to that server. Thus I can't use <code>DateTime.Now</code> of my own server, because they are not in sync. My server and the remote server have the same year, same month, same day, but they might sometimes even be off by hours.</p>
  
  <p>I saw <a href="https://stackoverflow.com/questions/6702705/how-to-convert-javascript-datetime-to-c-sharp-datetime">this question</a>, but answers assume that I have access to JavaScript code on that server to get time. I don't. I also saw <a href="https://stackoverflow.com/questions/1877788/javascript-date-to-c-sharp-via-ajax">this question</a>, but it's about sending my own client's time to my server. And as I said, I don't have access to creation of JavaScript's datetime. I only have access to data shown above.</p>
  
  <p>Now I need to:</p>
  
  <ol>
  <li>Parse this time, exactly as it is, down to milliseconds precision</li>
  <li>Tick based on this time, so that I can do something precisely at some point in time, relative to it</li>
  </ol>
  
  <p>I wanted to try <code>new DateTime(year, month, day, hour, minute, second, millisecond)</code>, but I don't have the number of milliseconds (it's in the last parameter called <code>msFormat</code> and I don't know it until I extract it, which is what I don't know).</p>
  
  <p>I tried <code>new DateTime(1970, 01, 01).AddMilliseconds(1590478340707)</code> which gives me a wrong time, because I know it's off even based on the remote server's time.</p>
  
  <p>I also tried <code>new System.Timers.Timer(1).Elapsed += HandleTimeBasedOnRemoteServerTime;</code>. But now I have no idea how to know the time of that server, because I can't use <code>DateTime.Now</code>.</p>
  
  <p>Could you please help?</p>