Set default time in bootstrap-datetimepicker

change picture change · Aug 2, 2013 · Viewed 202.1k times · Source

I want to set default time in this datetimepicker as 00:01 for the current date. Anyone tried that before? Having a tough time with it. It Seems simple.

$('#startdatetime-from').datetimepicker({
    language: 'en',
    format: 'yyyy-MM-dd hh:mm'
});

I need to use setDate, but I'm not sure how. I checked their code, but did not find a parameter for that.

Answer

Nicholas Hamilton picture Nicholas Hamilton · Feb 18, 2015

None of the above worked for me, however I had success setting the default at time of instantiation.

JQuery

<script type="text/javascript">
    $(function () {
        var dateNow = new Date();
        $('#datetimepicker').datetimepicker({
            defaultDate:dateNow
        });
    });
</script>