-1

I am trying to set the default date/time for a bootstrap 3 datetimepicker to today's date 08:00 AM.

The following code is what I have done. However, that does not seems to be setting the datetime for the field.

$(function(){

    $('#started-at').datetimepicker({
        format: 'MM/DD/YYYY LT',
        useCurrent: false,
        defaultDate: getDefaultStartAt()
    });
});

function getDefaultStartAt()
{
    var d = new Date();
    var month = d.getMonth();
    var day = d.getDate();
    var year = d.getFullYear();

    return new Date(year, month, day, 8, 0);
}

How can I correctly set the default value for bootstrap-datetimepicker?

Jaylen
  • 39,043
  • 40
  • 128
  • 221

1 Answers1

0

Your js code is fine.

You probably didn't include (or in wrong order) something from minimal requirements.
moment.js maybe?

Or your html could be wrong.

Here you can see working example with your code: https://jsfiddle.net/5vv9chgx/

Jakob
  • 3,493
  • 4
  • 26
  • 42