gpt4 book ai didi

javascript - JQ UI DatePicker - 时区

转载 作者:行者123 更新时间:2023-11-29 21:19:41 32 4
gpt4 key购买 nike

如何强制JQ UI DatePicker在给定时区而不是本地工作?

例如:美国/多伦多

最佳答案

我们可以用 momentJS 解决这个提议+ 设置默认日期选项 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() 来获取给定时区的正确日期和时间结果。

关于javascript - JQ UI DatePicker - 时区,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38783707/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com