在将数据从PHP传输到JavaScript时计算时区偏移量

Okay, this is sort of an odd question. In one of my modifications, the PHP code stores timestamps in a database using time() - as far as I know, this uses the UTC timezone. Now, I grab this data and use it as a parameter in some Javascript function. This function returns a time string similar to "30 seconds ago" or "2 hours and 30 minutes ago", etc etc. Here's the complete function:

time_string : function(seconds,complexity,seconds_left,suffix,prefix){
    var difference = Math.abs(dynamo.time - seconds);
    seconds_left = seconds_left == null ? 0 : seconds_left;
    seconds = +seconds;
    if(difference < 15 && !seconds_left){
        return "Just now";
    }
    suffix = suffix != null
        ? (seconds_left == 1
            ? ""
            : suffix)
        : (seconds_left == 1
            ? ""
            : " ago");
    prefix = prefix != null ? prefix : "";
    if(difference > 86400){
        return new Date(seconds * 1000).toDateString();
    } else {
        var years = Math.floor(difference / 31536000);
        var days = Math.floor((difference / 86400) % 365);
        var hours = Math.floor((difference / 3600) % 24);
        var minutes = Math.floor((difference / 60) % 60);
        var second = difference % 60;
        var time_str = [];
        if(years > 0) time_str[time_str.length] = dynamo.toolbox.format_number(years) + " year" + (years == 1 ? '' : 's');
        if(days > 0) time_str[time_str.length] = days + " day" + (days == 1 ? '' : 's');
        if(hours > 0) time_str[time_str.length] = hours + " hour" + (hours == 1 ? '' : 's');
        if(days <= 1){
            if(minutes > 0) time_str[time_str.length] = minutes + " minute" + (minutes == 1 ? '' : 's');
            if(second > 0 && !minutes && !hours && !days){
                time_str[time_str.length] = second + " second" + (second == 1 ? '' : 's');
            }
        }
        complexity = complexity != null ? complexity : 2;
        time_str = time_str.slice(0,complexity);
        if(time_str.length > 1){
            var final_str = time_str[time_str.length-1];
            time_str.pop();
            time_str = time_str.join(", ") + " and " + final_str;
        } else {
            time_str = time_str.join("");
        }
    }
    return prefix + time_str + suffix;
}

In the code, dynamo.time is used. dynamo.time is set to the current time() from PHP (which I use to work out the difference in time between the stored time and current time).

However, I need to adjust the difference variable to account for the client's timezone difference compared to the server's (which, as before, I believe is UTC).

How would I go about doing this?

In case you want it, here's a JS Fiddle with some testing on the function: http://jsfiddle.net/Jskjv/1/

EDIT: Would I be able to mess with new Date().getTimezoneOffset() to achieve this? Only thing is there will be inconsistencies with DST.

I'm not sure where the confusion comes from; assuming the visitor system clock is good enough, you can just compare any timestamp against this:

Math.round(new Date().getTime() / 1000)

It also returns the same kind of unix timestamp, so there's no complication of timezone offsets.

It's possible that the user system clock is too messed up. In those cases you can do a time offset calculation, whereby PHP's time() is passed via inline JavaScript. Again, no timezones :)