After a test, I draw a conclusion
And I could not find an option which can specify the Timezone, is this a bug, or have I missing sth?
The versions are
2.11.14.14.30There is a timeZone option but it is ignored if you are not also using the moment-timezone package. My (npm-managed) [email protected] wants moment-timezone ^0.4.0 but for some reason I had to manually install it. Once I did, I was able to specify a timeZone in the options hash.
This is not documented. ( #2118 )
Use moment.tz.setDefault('TimeZoneName'); to set the default timezone you want to use (e.g. moment.tz.setDefault('UTC'); to use UTC as default). You will need the moment-timezone package as mentioned by @thw0rted .
You can then convert the timezone to whatever timezone you want:
// guess current client's timezone
var guess = moment.tz.guess();
// get moment object from datetimepicker
var datetime = $('#datetimepicker').data("DateTimePicker").date();
// convert moment object's timezone
datetime.tz(guess);
// set moment object as new value for datetimepicker
$('#datetimepicker').data("DateTimePicker").date(datetime);
// also tell datetimepicker about the used timezone
$('#datetimepicker').data("DateTimePicker").timeZone(guess);
Hi, as @thw0rted this option is not documented but can actually be use I made a fiddle a while ago, and should bw working http://jsfiddle.net/tyw9dnhb/1/
Most helpful comment
Use
moment.tz.setDefault('TimeZoneName');to set the default timezone you want to use (e.g.moment.tz.setDefault('UTC');to use UTC as default). You will need themoment-timezonepackage as mentioned by @thw0rted .You can then convert the timezone to whatever timezone you want: