将jquery-ui-timepicker.js的'Now'按钮设置为UTC时区

时间:2013-10-15 04:06:09

标签: javascript date timezone utc jquery-ui-timepicker

我正在使用jquery-ui-timpicker-addon.js。我必须在GMT而不是当地时间设置时区。在下面的代码中,我可以更改GMT中的时间,但日期没有相应更新。请让我知道

$.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();

1 个答案:

答案 0 :(得分:2)

//this._setTime(inst, now_utc);
//$('.ui-datepicker-today', $dp).click();
$(id).datepicker('setDate', new Date(now_utc.getTime()));