2
我正在使用jquery-ui-timpicker-addon.js。我必須設置GMT時區而不是當地時間。在下面的代碼中,我可以更改格林尼治標準時間,但日期並未相應更新。請讓我知道將jquery-ui-timepicker.js設置爲'Now'按鈕至UTC時區
$.datepicker._gotoToday = function (id) {
var inst = this._getInst($(id)[0]), $dp = inst.dpDiv;
this._base_gotoToday(id);
var tp_inst = this._get(inst, 'timepicker');
var now = new Date();
var now_utc = new Date(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(), now.getUTCHours(), now.getUTCMinutes(), now.getUTCSeconds());
this._setTime(inst, now_utc);
$('.ui-datepicker-today', $dp).click();
這隻能說明你是如何構建'now_utc'。其餘的代碼不是jQueryUI日期選擇器的一部分,而是來自您自己項目中的其他部分。請僅顯示實際重現問題所需的部分。請記住,我們無法訪問您的源代碼。謝謝。 –