How to set specific timezone in datepicker using jquery only?

I have a field and applying datepicker on it using jQuery.

he is currently getting time from the system / browser.

I want it to get time from a specific time zone, such as America / new_york.

The parameter endDateis the key for setting the calendar, which means that the user will not be able to choose datefrom the future. Currently, it looks as follows

enter image description here

Code snippet:

jQuery('#convo_start_date').datepicker({
    format: 'dd M yyyy',
     endDate: '+0d',
     autoclose: true,
     showButtonPanel: true, 
     todayBtn: 'linked'
    }).on('change', function () {
        jQuery('.datepicker').hide();
        jQuery('#convo_end_date').attr('value',jQuery('#convo_start_date').val());
    });

Question: Is there a way to set a default time zone, such as America / new_york, so as not to allow a date from the future (according to this particular time zone)?

. moment.js, jQuery, - datepicker library ?

+4
2

Joda-Time, .

, , org.joda.time.DateTimeZone.

DateTimeZone Canonical, Joda.

, API.

, . .

0

jquery ui datepicker , maxDate , .

. targetTimeOffset .

var d = new Date();
var targetTimeOffset  = -4*60; //desired time zone, taken as GMT-4
d.setMinutes(d.getMinutes() + d.getTimezoneOffset() + targetTimeOffset );

Check Fiddle: http://jsfiddle.net/mpsingh2003/8w8v9/3387/, ,

0

Source: https://habr.com/ru/post/1683890/


All Articles