Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set a timezone in the datetimepicker?

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!

like image 986
imtk Avatar asked Jan 20 '15 19:01

imtk


2 Answers

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"
like image 72
lacostenycoder Avatar answered Oct 29 '22 17:10

lacostenycoder


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

like image 29
David Kim Avatar answered Oct 29 '22 19:10

David Kim