Date Pipe Angular it is not able to show only Month and Year it shows date, month and year

1.9k Views Asked by At

I am using bootstrap input date and saving a new Date from dialog box. But when I want to show I want only to show the month and year. I have added the pipe to show month and year but it shows month, year and date.

<input  name="startdate" [ngModel]="data.career.startDate | date: 'yyyy-MM-dd'"
                 (ngModelChange)="data.career.startDate = $event" type="date" class="form-control-sm">

This is how I save data.

And this is how I try to show date.

<input type="date" [ngModel]="subCategory.startDate | date: 'yyyy-MM-dd'" class="form-control-sm" readonly>

I tried here to write the pipe yyyy-MM but it didn't work.

I don't want to have the matpicker from angular material. It is possible only to show month and year ? Here is the current photo what I see. And only to show in format number not month as string . enter image description here

1

There are 1 best solutions below

3
On BEST ANSWER

<input type="date"> will always show local date format in supported browsers. To show formatted date, use <input type="text">