views:

41

answers:

2

I have a Chrome extension that relies heavily on a server back end to function. In a few weeks I'm going to need to do some changes on the server for about an hour. Is there any public API that can be used to get the time from a server (probably someone who's made one on appspot or something), all I need is to have everyone getting the same timestamp so I can disable the extension functionality at the same time for everyone. I can't use Date().getTime() because that is timezone specific and some people might have the wrong date or time set on their system.

+1  A: 

Well, you could just have a script on the server like this (PHP example, but other languages are similar):

<?php echo time(); ?>

and have your extension make a request to that script.

Delan Azabani
+1  A: 

If you are using any AJAX methods, you can rely on the Date header from the server to be the same for all clients. The usual way to get this is:

strDateString = xhr.getResponseHeader('Date');

Andrew