Reputation: 347
How to force JQ UI DatePicker work in given timezone, not local?
For example: America/Toronto
Upvotes: 3
Views: 2966
Reputation: 347
We could solve this propose with momentJS + set defaultDate option 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')
}
Remember: Don't call toDate() method, use format() for getting proper date and time result in given timezone.
Upvotes: 2