How can I set a timezone in the datetimepicker?

二次信任 提交于 2020-06-24 08:46:46

问题


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.

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!


回答1:


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




回答2:


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

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

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

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

"Difference to Greenwich time (GMT) in hours"


来源:https://stackoverflow.com/questions/28053858/how-can-i-set-a-timezone-in-the-datetimepicker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!