使用TimePiker,我希望设置时区:
$('#timeStart').timepicker({
showTimezone: true,
timeFormat: "hh:mm TT",
timezoneList:
[
{ 'value': '-720', 'label': '(GMT-12:00) International Date Line West' },
{ 'value': '-660', 'label': '(GMT-11:00) Midway Island, Samoa' }
....
{ 'value': '+840', 'label': '(GMT+14:00) Time in Samoa' }
]
});初始化了timepiker,并在选择器中添加了区域,但是如果我手动设置了时区:'+840‘,则不会检测到选中的值是第一个from列表:’+840‘。
为什么时区不是自动检测的?
发布于 2015-06-10 14:58:35
我找到了解决办法,而不是
{ 'value': '-720', 'label': '(GMT-12:00) International Date Line West' }需要使用
{ value: -720, label: '(GMT-12:00) International Date Line West' }发布于 2015-06-10 14:28:02
我不熟悉那个时间选择器,但是如果您可以手动选择它,请使用
new Date().getTimezoneOffset();你可能会想办法解决这个问题。
diff = new Date().getTimezoneOffset();
timediff = diff/-60;
currentTimezone = (timediff > 0)? "+" : "-";
currentTimezone = (Math.abs(timediff) >= 9)? currentTimezone + Math.abs(timediff): currentTimezone +"0"+ Math.abs(timediff);
currentTimezone += "00";
console.log(currentTimezone)https://stackoverflow.com/questions/30758813
复制相似问题