Javascript jqui日期选择器-时区
如何强制工作在给定的时区,而不是本地Javascript jqui日期选择器-时区,javascript,jquery,Javascript,Jquery,如何强制工作在给定的时区,而不是本地 例如:America/Toronto我们可以使用+set-defaultDate选项JQ UI DatePicker解决这个问题 //Set default timezone for all new momentJS instances moment.tz.setDefault('America/Toronto'); //Today date and time in America/Toronto timezone correction var setD
例如:
America/Toronto
我们可以使用+set-defaultDate选项JQ UI DatePicker解决这个问题
//Set default timezone for all new momentJS instances
moment.tz.setDefault('America/Toronto');
//Today date and time in America/Toronto timezone correction
var setDate = moment();
//Set defaultDate in proper date format for datepicker
$(element).datepicker(
{
defaultDate:setDate.format('MM/DD/YYYY')
}
记住:不要调用toDate()方法,使用format()在给定时区中获取正确的日期和时间结果。我认为默认情况下,datepicker上没有此功能。您需要计算出客户端的当前时区,然后添加/减去偏移量以获得TorontoCheck中的时间欢迎使用堆栈溢出!我尽我所能地编辑了你的问题。但是,请添加代码和说明,以便更多了解该主题的人能够看到它。请在遇到的特定错误消息中进行编辑,以防识别特定问题。祝你好运