node package manager


Synchronizes local browser time with server time using clock synchronization algorithm, similar to NTP.


  1. Ensure angular, and ng-server-time are installed correctly

    npm install
    npm install angular
    npm install ng-server-time
  2. Ensure you have an angular factory such as this one, it is required by the server time factory:

    app.factory('socket', function() {
       var socket = io.connect();
       return socket;
  3. Include ng-server-time-factory.min.js:

     <script src="/"></script> 
     <script src="/angular.min.js"></script> 
     <script src="/ng-server-time-factory.min.js"></script> 
     <script src="/my-angular-app.js"></script> 
  4. Initilaize the socket on the server:

    var server_time = require('ng-server-time');
    io.sockets.on('connection', function (socket) {


app.controller('MainController', function($scope, ServerTime){
    // on the server 
    $ =;
    // new Date() on the server 
    $ =;
    // get offset in milliseconds between current browser 
    // time and server time 
    $scope.getOffset = ServerTime.getOffset();