admin管理员组

文章数量:1426066

My Bootstrap 3 Datetimepicker is configured as:

 $(function () {
    $('#datetimepicker').datetimepicker({
        minDate: moment(),
        keepInvalid: $('#start_date').val() ? true : false,
        sideBySide: true
        });
});

What I really need is to show the current date and time (like moment() function does) only if the value of the input form is empty (i.e. the appropriate field in the database is empty). And do not show the current date&time if the value is set.

In the current configuration it always shows me the current date & time ignoring the value from the database. Any ideas?

My Bootstrap 3 Datetimepicker is configured as:

 $(function () {
    $('#datetimepicker').datetimepicker({
        minDate: moment(),
        keepInvalid: $('#start_date').val() ? true : false,
        sideBySide: true
        });
});

What I really need is to show the current date and time (like moment() function does) only if the value of the input form is empty (i.e. the appropriate field in the database is empty). And do not show the current date&time if the value is set.

In the current configuration it always shows me the current date & time ignoring the value from the database. Any ideas?

Share Improve this question edited May 27, 2022 at 16:17 Andremoniy asked Apr 25, 2016 at 14:05 AndremoniyAndremoniy 35k24 gold badges142 silver badges254 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 2

I have to use defaultDate property instead of minDate:

$(function () {
    $('#datetimepicker').datetimepicker({
        defaultDate: moment(),
        sideBySide: true
        });
});

本文标签: javascriptBootstrap datetimepicker current date and current time by defaultStack Overflow