-2

Although I use 'toISOString ()' in javascript, it recorded as in photo 2. How do I change this format.

Note: I am using AngularJs. picture 1 is list.component.ts

Additional files:

picture 1

picture 2

picture 1:

formatDate(e) {
  var convertDate = new
  Date(e.target.value).toISOString().substring(0, 10);
  this.studentForm.get('dob').setValue(convertDate, {
    onlyself: true
  })
}
adiga
  • 34,372
  • 9
  • 61
  • 83
  • Please post code, not images of code. As for your question: it implies that you have a `Date` object, and formatting those is a solved problem. And you can always use methods like `getMonth()` to compose the string yourself. –  Oct 04 '20 at 10:18

1 Answers1

0

You could use intl object provided by JS like this -

const date = new Date();
new Intl.DateTimeFormat('en-GB').format(date);
Piyush Rana
  • 631
  • 5
  • 8