How to change date input type to DD/MM/YYYY in Angular?

Viewed 3688

I am using property as input type ="datetime". But this property view the output MM/DD/YYYY. so how do I change the output format of the Date to DD/MM/YYYY?

pick the date format mm/dd/yyyy

                        <div class="form-group">
                            <label>{{"StartDate" | localize}}*</label>
                            <input required class="form-control m-input" type="datetime" bsDatepicker 
                            datePickerMomentModifier [(date)]="ticketWorkDetail.workDetailStartDate" 
                            id="TicketWorkDetail_WorkDetailStartDate" 
                            name="TicketWorkDetail_WorkDetailStartDate">
                        </div>
1 Answers

If you are using ngx-bootstrap... I think you are from the bsDatepicker directive on your input. You can use the bsConfig directive to format the date input. https://valor-software.com/ngx-bootstrap/#/datepicker#format

<div class="form-group">
    <label>{{"StartDate" | localize}}*</label>
    <input required class="form-control m-input" type="text" bsDatepicker 
    datePickerMomentModifier [(date)]="ticketWorkDetail.workDetailStartDate"
    [bsConfig]="{ dateInputFormat: 'DD/MM/YYYY' }" 
    id="TicketWorkDetail_WorkDetailStartDate" 
    name="TicketWorkDetail_WorkDetailStartDate">
</div>

You can set the input type attribute to text and the bsDatepicker directive will do it's work.

Related