Bootstrap Datetimepicker Today

Bootstrap Datetimepicker Today


What I need is to show current date and time, only if value of input form is empty.


I want my datetimepicker to have a default value which is the current date. But I search it but can't find anything to achieve that. I decided to solve it as follows


How to get current date in jQuery?


jquery getmonth


The getMonth() method returns the month (from 0 to 11) for the specified date. (Such as January is 0, February is 1, and so on.)


The getDate() method returns the day of the month (from 1 to 31) for the specified date.


The getFullYear() method returns the year (four digits for dates between year 1000 and 9999) of the specified date.


<script type="text/javascript">

    $(document).ready(function () {
        
        $('#updatedate').val(CurrentDate());
        
    });

    function CurrentDate()
    {
        var d = new Date();
        var month = d.getMonth() + 1;
        var day = d.getDate();
        var year = d.getFullYear();
        var output = (day < 10 ? '0' : '') + day + '/' + (month < 10 ? '0' : '') + month + '/' + year;

        return output;
    }
</script>

bootstrap-datetimepicker-today-1.PNG

tag : $('#').datetimepicker() today,datetimepicker today date,bootstrap datetimepicker today date,bootstrap datetimepicker defaultDate,jquery today