Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to instruct Datetimepicker that the time selected is of another timezone
    primarykey
    data
    text
    <p>I am using <a href="http://trentrichardson.com/examples/timepicker/" rel="nofollow">Timepicker</a> jQuery plugin in order to allow the input of time in addition to date.</p> <p>However, I have been struggling for some time to make it understand that the time that I actually pick is not the local time:</p> <p>My users are actually picking the time that a maintenance is going to take place in Hong Kong.</p> <p>So "2013/09/30, 14:00" is actually the time in Asia/Hong_Kong TimeZone.</p> <p>I have been using also the <a href="https://github.com/mde/timezone-js" rel="nofollow">timezone-js</a> library which is very good at manipulating and converting between timezones.</p> <p>My code is this:</p> <p>jQuery init:</p> <pre><code>jQuery(function (){ jQuery('#trouble_ticket_start, #trouble_ticket_end').datetimepicker({ changeMonth: true, changeYear: true, dateFormat: 'yy-mm-dd', showButtonPanel: true, gotoCurrent: true }); </code></pre> <p>Before anybody asks, I have installed the Olson timezone files correctly.</p> <p>Now firing up the JS Console in Chrome:</p> <pre><code>dt = jQuery("#trouble_ticket_start").datepicker("getDate"); &gt;&gt; Mon Sep 30 2013 14:00:00 GMT+0200 (CEST) </code></pre> <p>The above is correct. However, I want my timezone to default to Hong Kong. Is it possible to do it?</p> <p>I am moving on and convert that to a timezone-js object:</p> <pre><code>dtj = new timezoneJS.Date(dt, 'Asia/Hong_Kong'); &gt;&gt; timezoneJS.Date {_useCache: false, _tzInfo: Object, _day: 1, year: 2013, month: 8…} dtj.toString(); &gt;&gt; "2013-09-30 20:00:00" dtj.getTimezone(); &gt;&gt; "Asia/Hong_Kong" </code></pre> <p>This is of course correct. But how can I default my initial time pick to Hong_Kong timeZone?</p> <p>Thanks in advance...</p> <p>pR</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload