Here you can find the source of tz(timezone)
Date.prototype.tz = function(timezone) { var result = [], date; var utc = this.getTime(); var data = data_IANA[timezone.toUpperCase()]; if (data === undefined) { data = data_abbr[timezone.toUpperCase()]; }/*from ww w. ja v a 2 s. com*/ if (data !== undefined && data.constructor === String) { date = utc + (+data.split(':')[0] * 60 * 60 * 1000) + (((+data.split(':')[1]||0) * 60 * 1000) * (+data.split(':')[0] < 0 ? -1 : 1)); result.push(new Date(date).toISOString()); } else if (data !== undefined && data.constructor === Object) { for (var i in data) { date = utc + (+i.split(':')[0] * 60 * 60 * 1000) + (((+i.split(':')[1]||0) * 60 * 1000) * (+i.split(':')[0] < 0 ? -1 : 1)); result.push(new Date(date).toISOString() + '|(' + data[i] + ')'); } } return result; };
Date.prototype.getStdTimezone = function() { var jan = new Date(2015, 0, 1); var jul = new Date(2015, 6, 1); return Math.max(jan.getTimezoneOffset(), jul.getTimezoneOffset());
Date.prototype.getTimezone = function () { return this.toString().replace( /^.*? ([A-Z]{3}) [0-9]{4}.*$/, "$1").replace( /^.*?\(([A-Z])[a-z]+ ([A-Z])[a-z]+ ([A-Z])[a-z]+\)$/, "$1$2$3");
Date.prototype.getTimezoneOffset = function getTimezoneOffset() { if (this._timezoneOffsetStd === undefined) { var date1 = new Date(this.getFullYear(), this.getMonth(), this.getDate(), 0,0,0,0), temp = date1.toGMTString(), date2 = new Date(temp.substring(0, temp.lastIndexOf(" ")-1)); this._timezoneOffsetStd = (date2 - date1) / 60000; return this._timezoneOffsetStd; ...
Date.prototype.toClientTimezone = function () { var offset = new Date().getTimezoneOffset(); this.setTime(this.getTime() + (offset * 60 * 1000)); return this;
Date.prototype.toServerTimezone = function () { var offset = new Date().getTimezoneOffset(); this.setTime(this.getTime() - (offset * 60 * 1000)); return this;