javascript - change Initial min date in jquery datetimepicker -


i assigned

    $(function(){    var startdate = $('#datefrom'); var enddate = $('#dateto'); startdate.datetimepicker('option', 'mindate', new date(+new date()-2592000000)); //***here try init min date start date  startdate.datetimepicker({     showsecond: true,     dateformat: 'yy/mm/dd',     timeformat: 'hh:mm:ss',      onclose: function(datetext, inst) {         if (enddate.val() != '') {             var teststartdate = startdate.datetimepicker('getdate');             var testenddate = enddate.datetimepicker('getdate');             if (teststartdate > testenddate)                 enddate.datetimepicker('setdate', teststartdate);             }             // else {                 // enddate.val(datetext);             // }     },      onselect: function (selecteddatetime){         enddate.datetimepicker('option', 'mindate', startdate.datetimepicker('getdate') );     } }); enddate.datetimepicker({     showsecond: true,     dateformat: 'yy/mm/dd',     timeformat: 'hh:mm:ss',      onclose: function(datetext, inst) {         if (startdate.val() != '') {             var teststartdate = startdate.datetimepicker('getdate');             var testenddate = enddate.datetimepicker('getdate');             if (teststartdate > testenddate)                 startdate.datetimepicker('setdate', testenddate);         }         // else {             // startdate.val(datetext);         // }     },      onselect: function (selecteddatetime){         startdate.datetimepicker('option', 'maxdate', enddate.datetimepicker('getdate') );     } }); }); 

to activate 1 month past dates in datetimepicker. still shows activate dates current date.

here when initializing plugin set startdate min value 1 month later. want work.

i use plugin

plugin on github

lets have @ generated date, shall we?

> new date() sun may 18 2014 21:09:57 gmt-0700 (pdt) > new date(+new date() - 2592000) sun may 18 2014 20:26:46 gmt-0700 (pdt) 

it looks subtracting seconds,but +new date() converts , date expects milliseconds. have @ mdn documentation. if use milliseconds instead of seconds, works fine.

however, cleaner approach subtract 1 month:

var mindate = new date(); mindate.setmonth(mindate.getmonth() - 1); 

Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -