Best method for getting an accurate timestamp?
<p>I am working on an app where there is a need for a reliable, accurate timestamp in JavaScript. As such, I would prefer not to rely on the client system time. Although it is likely to be correct, I need something more certain.</p>

<p>I was hoping there was an API available from a well endowed provider such as Google that would allow me to access an accurate timestamp from some server somewhere. I haven't been able to find that, so I came up with another idea: create a tiny dummy file on our server, retrieve it via AJAX and extract our own server's timestamp from response headers: </p>

<pre><code>$.ajax({
 type: 'POST',
 url: 'dummy.json',
 complete: function (response) {
   // header is available as a string: response.getAllResponseHeaders();
 }
}
</code></pre>

<p>Headers:</p>

<pre><code>Date: Fri, 14 Oct 2011 14:07:41 GMT
Content-length: 18
Last-modified: Thu, 13 Oct 2011 20:35:28 GMT
Server: Netscape-Enterprise/6.1 AOL
Etag: "0-0-12-0"
Content-type: text/plain
Accept-ranges: bytes
</code></pre>

<p>Is this not the most ridiculous work-around ever? Am I going crazy? Is there a better solution?</p>

<p>If not could somebody help me write a regex to extract just the date from the above response header string?</p>

<p>edit: forgot to mention the reason why this is a problem is I don't have access to the backend to create some simple service for polling a timestamp from the server or anything like that. I have to do it in JavaScript for this particular application.</p>
