0

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

TheCoderGuy
  • 771
  • 6
  • 24
  • 51

1 Answers1

1

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

kvetis
  • 6,682
  • 1
  • 28
  • 48
  • I never thought about that. Thank you it works. How it is possible in dialog box only to ask for month and year without day. Can u help me on that ? @kvetis – TheCoderGuy Sep 21 '20 at 14:56
  • You can use `input type="month"` if you have control of the browser the appliaction is used in. It is only supported in [some browsers](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/month#Browser_compatibility). – kvetis Sep 21 '20 at 15:20
  • Yeah to shame that for some browsers that doesnt work. – TheCoderGuy Sep 21 '20 at 15:21