Topic: Customizing DatePicker and TimePicker

nmishra pro asked 8 years ago


Hi, I am having one more doubt. How can I customize datepicker and timepicker. Below I am mentioning my requirement and how earlier I solver it with bootstrap-datepicker and bootstrap-timepicker. DatePicker: I want to disable selecting back dates. This is the code snippet which I used while using bootstrap-datepicker $('#odate').on('click', function(){ $(this).datepicker({ format: 'dd-mm-yyyy', autoclose: true, startDate: '23-01-2016' }); }); Current Issues with MDB Datepicker: Unable to disable previous dates and while selecting the next month modal is getting closed. TimePicker: I want a control such that a user can select time only between a certain time interval. This is how I was doing it while using bootstrap-timepicker. //${t}: time which I am sending from the server. Its format is hh:mm:ss $('#timepicker1').timepicker({ showMeridian: false, defaultTime: '${t}' }).on('changeTime.timepicker', function(e) { var h= e.time.hours; var m= e.time.minutes; var cd = new Date($('#odate').val().split('-').reverse().join('-')); var dd = new Date('${dt}'.split('-').reverse().join('-'));//console.log((+cd==+dd), cd, dd, $('#odate').val().split('').reverse().join(''), '${dt}'); if (h<Number('${t}'.substring(0,2))&&(+cd==+dd) ){ $('#timepicker1').timepicker('setTime', '${t}'); popover.options.content = 'For deliver later option, time must be greater than ${t}' ; $('#deltime').focus().blur(); } else if ( (h===Number('${t}'.substring(0,2))) && (m<Number('${t}'.substring(3))) && (+cd==+dd) ) { $('#timepicker1').timepicker('setTime', '${t}'); popover.options.content = 'For deliver later option, time must be greater than ${t}' ; $('#deltime').focus().blur(); } else if (((h>=22 ) && (m>15)) || ((h<=10 ) && (m<59)) ){ $('#timepicker1').timepicker('setTime', '${t}'); popover.options.content = 'We deliver between 10:59 and 22:15' ; $('#deltime').focus().blur(); } else{ //console.log($('#timepicker1').val()); } }); Thank you. PS: Your both the timepicker and datepicker is really amazing and appealing

Michal Szymanski staff answered 8 years ago


Could you write me what exactly have you changed before?

nmishra pro answered 8 years ago


Thank you. And why is it not getting initialized?

Michal Szymanski staff answered 8 years ago


Take a look here, but the API is very poor: http://weareoutman.github.io/clockpicker/

nmishra pro answered 8 years ago


Thank you for the pickadate api link. My issue with datepicker is resolved. One strange issue I'm facing with timepicker is that its not getting initialised now. Could you please tell me what could be the possible reason. And where can I check out the source code or some api link for timepicker. THank you

Michal Szymanski staff answered 8 years ago


Hi, first of all I have to apologize you, because both datapicker and time picker are far away from being perfect and finished. I would recommend you to take a look at detailed documentation of datapicker. Be aware not all option were implemented yet in MDB. http://amsul.ca/pickadate.js/api/ And about timepicker - because it's completely custom component (not event bootstrap based) I cannot offer you any ready solution for your issue, because it's not developed yet. I'm sorry.

Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Specification of the issue

  • ForumUser: Pro
  • Premium support: No
  • Technology: General Bootstrap questions
  • MDB Version: -
  • Device: -
  • Browser: -
  • OS: -
  • Provided sample code: No
  • Provided link: No
Tags