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