jquery - How to find today's date in DateTimePicker JavaScript? -


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. wrote following function in js:

<script> var today = new date(); var dd = today.getdate(); alert(dd);            var logic = function( currentdatetime ){   if( currentdatetime.getday()==dd ){     this.setoptions({       formattime:'g:i a',  format: 'd/m/y h:i a',   mindate:'+1970/01/02',//today   mintime: //i don't know yet how implement current time     });   }else     this.setoptions({      formattime:'g:i a',  format: 'd/m/y h:i a',   mindate:'+1970/01/02'//today     }); };                   jquery('#datetimepicker').datetimepicker({                 onchangedatetime:logic,                 onshow:logic                 });  </script> 

the problem that line:

currentdatetime.getday()==dd 

doesn't work, because in case dd equals todays day of month (e.g. 25), , currentdatetime.getday() checks current day of week (e.g. saturday it's 6). there me issue? know there other available solutions (other datetime pickers), cannot find other simple , elegant this. thanks!

you want use getdate() returns day in month, instead of getday() returns day in week.

you should read date reference page.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -