trentrichardson / jQuery-Timepicker-Addon

Adds a timepicker to jQueryUI Datepicker
http://trentrichardson.com/examples/timepicker/
MIT License
2.66k stars 1.05k forks source link

How to set default value or timezone? #808

Open rexsalescatalysts opened 9 years ago

rexsalescatalysts commented 9 years ago

hi, I am trying to display the time text in datetimepicker as timezone related. First method that I have tried is to set timezone in datetimepicker({timezone: +60}), but it seems not working. Then I tried to set the default value directly by datetimepicker({defaultValue: '2015-05-06 01:00:00'}), it is not working as well. I would like to ask about the correct steps or syntax to set timezone or default value. Thank you.

joaogac commented 9 years ago

Hi @rexsalescatalysts !

I've struggled with this issue for a few days digging into the docs without success. As a workaround, we used the dumbiest solution as you can imagine: just simply set the default value as jQuery('#textInputId').val('2015-05-06 01:00:00 +0600') (or your desired timezone) after datetimepicker initialization.

Hope this works for someone else. Cheers.

ejazrasool commented 8 years ago

Pretty old issue but I'll include the solution to help future readers.

You can use "timezone" key while initializing the datetimepicker as follows

$('#blah').datetimepicker({
    timezone: -240
});

Documented here http://trentrichardson.com/examples/timepicker/#tp-formatting