Looking to convert ISO date string on load in bootstrap/angular to 'MM/DD/YYYY'
Currently on load this is how the date picker looks: https://i.stack.imgur.com/g5MkI.jpg
We need the input date entered as 'MM/DD/YYYY' and then converted to ISO format
HTML
<form class="form-inline">
<div class="form-group">
<div class="input-group">
<input class="form-control"
name="dp" [(ngModel)]="model" ngbDatepicker #d="ngbDatepicker"
[min]="minDate"
[max]="maxDate"
[style.width]="inputWidth"
class="form-control"
>
<div class="input-group-append">
<button class="btn btn-outline-secondary" (click)="d.toggle()" type="button">Pick Date
<i class="fa fa-calendar"></i>
</button>
</div>
</div>
</div>
</form>
{{model.toISOString().substring(0,10)}}
TS
import {Component, Input} from '@angular/core';
import {NgbDateAdapter, NgbDateNativeAdapter} from '@ng-bootstrap/ng-bootstrap';
@Component({
selector: 'datepicker',
templateUrl: './datepicker-popup.html',
providers: [{provide: NgbDateAdapter, useClass: NgbDateNativeAdapter}]
})
export class NgbdDatepickerPopup {
model: Date;
@Input() disabled = false;
@Input() required = false;
@Input() displayValidation = false;
@Input() minDate = null;
@Input() maxDate = null;
@Input() public inputWidth = '135px';
dateInputMask = [/\d/, /\d/, '/', /\d/, /\d/, '/', /\d/, /\d/, /\d/, /\d/];
@Input() private format = 'YYYY-MM-DD';
private inFormat = 'MM/DD/YYYY' || 'YYYY-MM-DD';
}
Currently the ISO format is working fine across the board but we need the user to be able to start with entering 'MM/DD/YYYY' format