0

I want to change the default 5 minutes increment/interval on the OOTB Date Picker WebPart on a SP13 custom list to a longer interval (such as 15 minutes). How does one achieve this?

I am fairly new to SharePoint (and JS/JQuery) so please explain with good details so that a "noob" can understand. Thank you!

bumped to the homepage by Community 8 hours ago

This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.

0

This should work in a Script Editor web part. Note that this will affect every date/time field on the screen.

<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script type="text/javascript">

$(document).ready(function() {
    $('[id*="$DateTimeFieldDateMinutes"]').empty().append(
'<option selected="selected" value="00">00</option><option value="15">15</option><option value="30">30</option><option value="45">45</option>');

});

</script>
  • Would this same code work to change the drop down for the HOUR (not just minutes) so it would read the "day starts" at 7 AM instead of 12 AM and ends at 4 PM instead of 11 PM? – D. Schmidt Jan 18 '18 at 22:23
  • It would, you just need to find the ID of the hour drop down. Use the F12 debugger to inspect it. – mannaggia Jan 19 '18 at 0:03
0

The code below for your reference:

<script src="//code.jquery.com/jquery-1.12.4.min.js"></script>
<script type="text/javascript">
$(function () {
    $("select[id$='_$DateTimeFieldDateHours'] option").each(function(){
        var array=["0","1","2","3","4","5","6","17","18","19","20","21","22","23"];
        for(var i=0;i<array.length;i++){
            if($(this).val()==array[i]){
                $(this).remove();
            }
        }
    });
    $("select[id$='_$DateTimeFieldDateMinutes'] option").each(function(){
        var array=["05","10","20","25","35","40","50","55"];
        for(var i=0;i<array.length;i++){
            if($(this).val()==array[i]){
                $(this).remove();
            }
        }
    });
});
</script>

enter image description here

  • OMG! Absolutely works wonderfully! So, now I plead with you to help me understand just how the code actually works - When I look at your code it appears that you are accounting for all 24 hours and 5 minute increments yet when implemented it displays only 7am to 4 pm and the minute increments are in 15-minute blocks exactly like I want. Beautiful, but perplexing! – D. Schmidt Jan 19 '18 at 14:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.