jQuery 如何在 datetimepicker 中设置时区?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28053858/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 11:30:00  来源:igfitidea点击:

How can I set a timezone in the datetimepicker?

jquerytimezonedatetimepicker

提问by leandrotk

I'm using this datetimepicker jquery plugin: http://xdsoft.net/jqplugins/datetimepicker/and I didn't get it how to use timezone. I saw the documentation, but I couldn't find it.

我正在使用这个 datetimepicker jquery 插件:http: //xdsoft.net/jqplugins/datetimepicker/,但我不知道如何使用时区。我看到了文档,但我找不到它。

What I tried to do is something like that:

我试图做的是这样的:

serviceDateTime.datetimepicker({
    lang: 'pt-BR',
    format: 'd/m/Y H:i',
    mask: true,
    step: 30,
    showTimezone: true,
    timezone: "-0200"
  });

Any help? Thanks in advance!

有什么帮助吗?提前致谢!

回答by David Kim

The plugin is simply used to give the user an interface to pick date and time.

该插件仅用于为用户提供一个界面来选择日期和时间。

If you're concerned about the display to be based on your timezone, see if this helps:

如果您担心显示基于您的时区,看看这是否有帮助:

Accounting for Timezone with jQuery datepicker

使用 jQuery datepicker 计算时区

回答by lacostenycoder

This was difficult to find in the documentation, but you can pass Oin formatto tell the plugin to pass the GMT offset.

这是很难的文档中找到,但你可以通过Oformat告诉插件传递GMT偏移。

serviceDateTime.datetimepicker({
    lang: 'pt-BR',
    format: 'd/m/Y H:i O',
    mask: true,
    step: 30,
    showTimezone: true,
});

The detective work was to find

侦探工作是要找到

https://xdsoft.net/jqplugins/datetimepicker/#use_other_date_parser

https://xdsoft.net/jqplugins/datetimepicker/#use_other_date_parser

Then from there https://github.com/kartik-v/php-date-formatter#features

然后从那里https://github.com/kartik-v/php-date-formatter#features

Then follow http://php.net/manual/en/function.date.phpand search page for

然后按照http://php.net/manual/en/function.date.php并搜索页面

"Difference to Greenwich time (GMT) in hours"