JavaScript DateTimePicker - Disable the times that have already passed in the day (JQuery) datetimepicker disable time,datetimepicker disable time intervals,datetimepicker disable time

I currently integrating the XDSoft DateTimePicker (http://xdsoft.net/jqplugins/datetimepicker/) JQuery into my website and wish to disable the times that have passed. Currently if i select today then i can still select a time which has already passed.

I tried using minTime:0 but this also disables times on sunsequent days. I want to be able to select a start and end time (e.g. 9am-5:30pm) which i can do with mintime and max time but i cant disable the times which have already passed today.

Below is my script:

<script>
    jQuery('#datetimepicker3').datetimepicker({
        minDate: 0,
        step: 60,
        minTime: '09:00',
        maxTime: '17:30',
        todayButton: true,
        format: 'd.m.Y H:i',
        inline: true,
        lang: 'en'

    });</script>
Answer:1

Yes setting minTime to 0 will disables times on subsequent days also. You need to change the minTime option depending upon the date. If it is today, minTime will remain the same, else minTime will be set to false.

$("#element").datetimepicker({ format: 'Y-m-d H:i', minDate: 0, minTime: 0, onSelectDate: function(ct) {
        var dtob = new Date(),
            current_date = dtob.getDate(),
            current_month = dtob.getMonth() + 1,
            current_year = dtob.getFullYear();

        // today's date 
        var full_date = current_year + '-' +
                        ( current_month < 10 ? '0' + current_month : current_month ) + '-' + 
                        ( current_date < 10 ? '0' + current_date : current_date );

        // compare today's date to the date chosen
        if(ct.dateFormat('Y-m-d') == full_date)
            this.setOptions({ minTime: 0 });
        else 
            this.setOptions({ minTime: false });    
    } 
});
Answer:2

Here i add a delay in javascript forloop using $timeout. Unexpectedly i got an error saying ReferenceError $timeout is not defined. i am new to angularjs please help me. PLNKR function CompLibrary(...

Here i add a delay in javascript forloop using $timeout. Unexpectedly i got an error saying ReferenceError $timeout is not defined. i am new to angularjs please help me. PLNKR function CompLibrary(...

  1. referenceerror $timeout is not defined

in dreamweaver cc 2015, when i am using the comparison operators in jquery/javascript programming like: if(x == "") DW shows an error that Expected === and instead saw ==. My question is that what ...

in dreamweaver cc 2015, when i am using the comparison operators in jquery/javascript programming like: if(x == "") DW shows an error that Expected === and instead saw ==. My question is that what ...

  1. jquery javascript comparison
  2. jquery vs javascript comparison
  3. jquery d3.js comparison
  4. jquery vs javascript code comparison

How does javascript run the tasks? I've recently started programming javascript, and after playing around with this, what i thought, simple project. That simply play some music, while some pictures ...

How does javascript run the tasks? I've recently started programming javascript, and after playing around with this, what i thought, simple project. That simply play some music, while some pictures ...

Alright, so my protractor test works if I'm not using a mock backend, and everything works as expected when I manually test the functionality (even with a mock backend). The only thing that doesn't ...

Alright, so my protractor test works if I'm not using a mock backend, and everything works as expected when I manually test the functionality (even with a mock backend). The only thing that doesn't ...

  1. protractor test fails
  2. protractor test failed element not visible
  3. protractor tests fail randomly
  4. protractor fail test manually
  5. protractor fail test case
  6. protractor fail test on purpose
  7. protractor first test always fails