title: Using server time to create a timer in Meteor
body: <p>I am trying to create a timer using the server time in meteor. On the client side, inside the <code>Meteor.startup</code> function, I make a call to the server to get the server time and keep it in a session variable. After that this server call will be made every 15 minutes using <code>Meteor.setInterval</code> function. </p>
  
  <p>On server <code>main.js</code>,</p>
  
  <pre><code>return Meteor.methods({
  
      getServerTime: function () {
          var d = new Date().getTime();
          return d;
      }
  
  });
  </code></pre>
  
  <p>On Client <code>main.js</code> ,</p>
  
  <pre><code>Meteor.startup(function() {
  
     Session.set('serverTime', false);
      // get serverTime on startup
      Meteor.setServerTime();
      // update serverTime every 15min
      Meteor.setInterval(function() { Meteor.setServerTime(); }, 900000);
  
  
  });
  
  Meteor.setServerTime = function() {
    //get server time (it's in milliseconds)
    Meteor.call("getServerTime", function (error, serverTime) {
  
      Session.set('serverTime', serverTime);
  
    });
  };
  </code></pre>
  
  <p>On the client side timer template code, I get the server time from session, <code>Session.get('serverTime');</code>, for use in the timer code. The problem is, if I have the timer taken on two different browsers and refresh one of them, timer is changed on that browser not affecting the timer on the other browser because of keeping the server time on session.</p>
  
  <p>I am looking for a way so that whatever the user does on his/her browser the timer is not affected and it should always be same of every browser using the sever time.</p>
  
  <p>Is there any other way/idea to tackle this scenario and keep the timer uniform everywhere?</p>
  
  <p>Thanks in advance.</p>