Q:

Progression bar sync javascript to server time?

I have an object which contains some data about progression of a bar but it keeps stopping at 99% and won't continue, i believe its because client time is not going to be the same as server time accurately enough to do it. So i don't know how to solve it.
These 2 timers are created server side and sent to the client.
myOjb[i].end: 1374805587 //seconds since epoch for when 100% is made
myObj[i].strt: 1374805527 //seconds since epoch when it started

The function that is calculating the percentage :
function clocker() {
    var now = new Date().getTime() / 1000;
    for (var i in myObj) {
        if (myObj[i].end > now) {
            var remain = myObj[i].end - now;
            var per = (now - myObj[i].strt) / (myObj[i].end - myBuildings[i].strt) * 100;
            var per = fix_percentage(per); // stops > 100 and < 0 returns int if true

            myObj[i].percentage = Math.ceil(per);

            console.log(myObj[i].percentage); //reaches 99 max

            if (myObj[i].percentage > 99) {
                console.log('test'); //never occurs
                return false;
            }
            break;
        } else {
            continue;
        }
    }
    setTimeout(clocker, 1000);
}

function fix_percentage(per){
    if(per>100)per=100;
    if(per<0)per = 0;

    return Math.round(per);
}

How could i sync the two together so the timing is more accurate ?

A:

Edit: Original answer was based on a bad assumption. I think what is happening is that essentially your block setting the percent to 100 might be getting skipped. This would happen if on one iteration, the value of per was < 99.5 but > 88.5. In this case, the rounded per would have a value of 99. Then, one second later when the function gets called again, the outer if block would not be entered due to myObj[i].end > now being false. The following code will make sure that if time expires and the myObj[i].percentage is < 100 because of the above scenario, it will be set to 100 and return like the other if block does.
if (myObj[i].end > now) {
        var remain = myObj[i].end - now;
        var per = (now - myObj[i].strt) / (myObj[i].end - myBuildings[i].strt) * 100;
        var per = fix_percentage(per); // stops > 100 and < 0 returns int if true

        myObj[i].percentage = Math.ceil(per);

        console.log(myObj[i].percentage); //reaches 99 max

        if (myObj[i].percentage > 99) {
            console.log('test'); //never occurs
            return false;
        }
        break;
    } else if ( (now >= myObj[i].end) && (myObj[i].percentage < 100) ) {
        console.log('Time expired, but percentage not set to 100')
        myObj[i].percentage = 100;
        return false;
    } else {
        continue;
    }

