Search code examples
htmlangularng-bootstrap

Angular / ng-bootstrap datetime format


I need help on how to get ng-bootstrap datetimepicker, instead of just datepicker.

This link shows datepicker separate and timepicker separate but I want a datetimepicker instead. Here is the format that want: 2019-09-10 12:54:30.963852.

Is there a way to get that format using ng-bootstrap?

Below is HTML example for ng-bootstrap datepicker:

<div class="form-group">
    <label>Date:</label> <input type="text" class="form-control" placeholder="yyyy-mm-dd" ngbDatepicker #d="ngbDatepicker"**strong text** required>
    <button (click)="d.toggle()"><i class="glyphicon glyphicon-calendar"></i></button>
</div>

Thanks


Solution

  • With normal Bootstrap you can specify the format:

    format: 'Y-M-D hh:mm:ss:SSSSSS'
    

    See this example: https://jsfiddle.net/6v8zs7a5/2/

    Something like this should work with ng-bootstrap as well.