jadeite1000
jadeite1000

Reputation: 659

how set the datepicker in moment.js to YYYY-MM-DD

I am using Moment.js with Angular 8: I am using the following html: But I am getting "mm/dd/yyyy" in the input box but I want "yyyy-mm-dd". In moment.js url it stated it should be "yyyy-mm-dd" by default(https://momentjs.com/docs/).

  <input id="startDate" name="startDate" type="date" [(ngModel)]="report.startDate" required 
#startDate="ngModel"/>

enter image description here enter image description here

Any help or hint would be greatly appreciated it!!

Upvotes: 1

Views: 2449

Answers (1)

Michaela D
Michaela D

Reputation: 46

The format keyword will allow you to define how you want the date displayed.

moment().format('YYYY-MM-DD');  

Upvotes: 2

Related Questions