I am using datepicker and I have the following code:
<mat-form-field>
<input matInput
[matDatepicker]="picker"
placeholder="select a date"
(dateChange)="setDate($event.value)">
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
<mat-datepicker #picker></mat-datepicker>
</mat-form-field>
<mat-form-field>
<input matInput type="time" value="16:30">
</mat-form-field>
<input matInput value="{{ date | date: 'y-MM-dd' }}">
In this datepicker example there is a US date format. I would like to use Australian date format which is dd/mm/yyyy. I am able to create a hidden input and convert it to yyyy-mm-dd format for database purposes but I am unable to show dd/mm/yyyy format in the datepicker input. Could you please help me to show Australian date format instead of US date format in the datapicker field?
Also Is it a good practice the way I am sending the dateformat for DB purposes?
.TS file
date: string;
setDate(date: string) {
this.date = date ? date : 'y-MM-dd';
.HTML file
input matInput [matDatepicker]="picker" placeholder="select a date"
(dateChange)="setDate($event.value)">
and
<input type="hidden" matInput value="{{ date | date: 'y-MM-dd' }}">