I would like to generate in JS a Date object (or XDate) starting from a UTC unix timestamp, add a timezone offset and then generate a String in the format "yyyy-MM-dd HH:mm:ss". For now I did this:
createServerRelativeTs : function(unixtimeutc, utcoffset) {
var stimeUTCoffset = (isNaN(utcoffset)) ? 1 : utcoffset;
var time = new XDate(Math.round(unixtimeutc * 1000));
var hours = time.getUTCHours() + stimeUTCoffset;
time.setUTCHours(hours);
return time.toString("yyyy-MM-dd HH:mm:ss");
}
in which utcoffset is a integer number and unixtimeutc is a unixtimestamp The problem with this code is that If I change the timezone in my OS the result changes! If I add the offset value to the timestamp it gets ignored. How can I get a OS-timezone-independent result?