javascript - Why I cannot disable some dates in datetimepicker based on my logic in jquery? -


i'm using following javascript: http://xdsoft.net/jqplugins/datetimepicker , , want achieve simple effect - when user selects today's day, should show him hours available until end of day, previous time should disabled. when choses other day in future - whole time should available. , 1 more thing - want use american timezone time, server php. later on i'm using moment.js parse , i'm including in datetimepicker. wrote following function in js:

$(document).ready(function () {       var today;     var time = 1443571620;     var newyorktime = time - 5*60*60;         today = new date(newyorktime*1000);         var dd = today.getdate();         var mm = today.getmonth();         var yy = today.getfullyear();         var hh = today.gethours();          var = new date(newyorktime*1000);         now.sethours(now.gethours());          var ispm = now.gethours() >= 12;         var ismidday = now.gethours() == 12;         var result = document.queryselector('#result');         var time = [now.gethours() - (ispm && !ismidday ? 12 : 0),             now.getminutes()].join(':') +                 (ispm ? ' pm' : 'am');         alert(now);          var logic = function (currentdatetime) {             var currentdatetimestamp = moment(currentdatetime).unix()-5*60*60;             currentdatetime = new date(currentdatetimestamp*1000);             if (currentdatetime.getdate() == dd && currentdatetime.getfullyear() == yy && ((currentdatetime.getmonth()) == mm)) {     alert(now);                  this.setoptions({                     formattime: 'g:i a',                     format: 'd/m/y h:i a',                     mindate: '1970/01/02', //or 1986/12/08,                     mintime: time                 });             } else                 this.setoptions({                     formattime: 'g:i a',                     format: 'd/m/y h:i a',                     mindate: '+1970/01/02', //or 1986/12/08,                     mintime: '0:00 am'                 });         };          $('#datetimepicker').val(dd+"/"+(mm+1)+"/"+yy+" "+time);         jquery('#datetimepicker').datetimepicker({             onchangedatetime: logic,             onshow: logic         });   } );   

currently doesn't work enough - when enter if (currentdatetime.getdate() == dd && currentdatetime.getfullyear() == yy && ((currentdatetime.getmonth()) == mm)) { if statement - i'm not able block previous hours somehow. how can that?

in general - let's it's 30th of september, 11am. when user clicks datetimepicker, should see available dates/times starting 30th of september 11am (previous dates/hours should greyed out). when chooses next days - hours should enabled , should have possibility of choosing them. doesn't work. please help..

here fiddle: http://jsfiddle.net/b8o5cvdz/8/


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -