Open hysterix opened 13 years ago
Yes this fixed it after spending hours!! thanks
That's great, I was just looking for how to make the "Now" button set the time in GMT instead of local time. Sounds like this is exactly what I need.
In the $.extend(TimePicker.prototype), _newInst function definition, there's a section where we build up a new instance and populate its fields with values from the _defaults object. I added the following:
tp_inst.timezone = tp_inst._defaults.timezone;
near the section of code where the hour, minute, etc... fields are assigned, like so:
tp_inst.timezone = tp_inst._defaults.timezone;
tp_inst.hour = tp_inst._defaults.hour;
tp_inst.minute = tp_inst._defaults.minute;
tp_inst.second = tp_inst._defaults.second;
tp_inst.millisec = tp_inst._defaults.millisec;
tp_inst.ampm = '';
Is this a correct alternative fix for this issue? (v.0.9.7)
This doesn't work for me. I've added the two fixes mentioned above, but if I try overriding the timezone to America/New_York and I set my local time to India Standard Time and click the "Now" button it always changes the value to India Standard Time.
I agree with redijedi - wilwayco fixes the problem, except if you click Now at which time the default TZ is put back into the input.
I just hid the Now button using CSS ;-)
What would be involved in adding an option that made the "Now" button always use a timezone you specify? I've got a use-case for "Now" meaning "Now, in GMT" as well. Going to hide the Now button with CSS, but I'd love to have the functionality.
I need the same functionality as fvox13. I'm working a system where the user can pick a time zone they want all of their time zones in for both display end editing (it will often be a different time zone than the one they have their computer set to), and I need it so that clicking 'Now' yields a date/time in the selected time zone ... the way it works now it ALWAYS gives a the current date/time in the computer's local time zone.
+1 to fix this issue. I also need the Now button to set a time in the configured zone. The fixes above did not work for me. Instead I overrode the $.datepicker._gotoToday method as shown below. This code can be put into your own javascript file so you don't have to modify the jQuery-Timepicker-Addon source code in the distribution. (This works with version 1.5.0 of jQuery-Timepicker-Addon. I have not tested any other version.)
$.datepicker._gotoToday = function (id) {
var inst = this._getInst($(id)[0]);
this._base_gotoToday(id);
var tp_inst = this._get(inst, 'timepicker');
var tzoffset = $.timepicker.timezoneOffsetNumber(tp_inst.timezone);
var now = new Date();
now.setMinutes(now.getMinutes() + now.getTimezoneOffset() - tzoffset);
this._setTime(inst, now);
this._setDate(inst, now);
};
'''
What is the status of this one?
I'd also like to see this feature implemented. (hitting "now" would fill the field with eg UTC)
I applied the changes mentioned by @gwikle however after further testing it was not working properly. For example in the docs the first example I press Now and I 17:50 when I should have gotten 11:50. I am at -0400 timezone so perhaps instead of subtracting it should have added the timezone (it would be negated tzoffset). I applied this tweak to the dev branch.
Hello,
I am creating an application, and your fork has helped me out a lot. I ran into a small problem, and that was trying to override the default value for timezone wasn't working, it was always defaulting to the hard-coded value, even though I was putting the correct information upon creating the object.
The timezone field wasn't working, I tracked it down and my fix was as follows:
Inside the function _injectTimePicker, add this line: // override default timezone value this.timezone = o.timezone;
Before this line, "if ($dp.find("div#ui-timepicker-div-"+ dp_id).length === 0 && o.showTimepicker) {"
That should allow you to override the default timezone value. Hope this saves someone else some time.