// Small jQuery plugin to get dates from server.
(function($){

    var serverDate;
    var init = function(){
        if (!serverDate) {
            $.ajax({
                "url": "/course-signup/rest/user/current",
                "type": "GET",
                "async": false,
                "dataType": "json",
                "success": function(data){
                    serverDate = data.date;
                }
            });
        }
    };
    
    $.serverDate = function(){
        init();
        return serverDate;
        
    };
})(jQuery);

// Small jQuery plugin to get dates from server.
(function($){

	// Work out the difference between client time and server time.
    var adjustment;
	
    var init = function(){
        if (!adjustment) {
            $.ajax({
                "url": "/course-signup/rest/user/current",
                "type": "GET",
                "async": false,
                "dataType": "json",
                "success": function(data){
                    var serverDate = data.date;
					var clientDate = new Date().getTime();
					adjustment = serverDate - clientDate;
                }
            });
        }
    };
    
    $.serverDate = function(){
        init();
        return (new Date().getTime() + adjustment);
        
    };
})(jQuery);

Make sure serverdate updates using the client clock.
Make sure serverdate updates using the client clock.