jQuery-Timepicker-Addon
jQuery-Timepicker-Addon copied to clipboard
calculate UTC
trafficstars
Is it possible to calculate the UTC time from a client as well ? As you can get the current time I would believe that getting the UTC also would be possible as well and put in some some (hidden) formfield.
see https://stackoverflow.com/questions/13479416/how-to-set-now-button-on-jquery-ui-datetimepicker-to-set-utc-time
/*
- override "Today" button to also grab the time. */ $.datepicker._base_gotoToday = $.datepicker._gotoToday; $.datepicker._gotoToday = function (id) { var inst = this._getInst($(id)[0]), $dp = inst.dpDiv; this._base_gotoToday(id); var tp_inst = this._get(inst, 'timepicker'); selectLocalTimezone(tp_inst); var now = new Date(); this._setTime(inst, now); $('.ui-datepicker-today', $dp).click(); }; and simply add the below change,
var now = new Date(); var utcNow = new Date(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(), now.getUTCHours(), now.getUTCMinutes(), now.getUTCSeconds()); this._setTime(inst, utcNow);