I am having a variable which is a NgbDateStruct object in the typescript file and would like to convert it into a String of the following format: "YYYY-MM-DD".
currentDate: NgbDateStruct;
When I console.log(this.currentDate) it is showing a Moment object.
console.log(this.currentDate);
Moment {_isAMomentObject: true, _i: '2021-12-1', _f: 'YYYY-MM-DD', _isUTC: false, _pf: {…}, …} _d: Wed Dec 01 2021 00:00:00 GMT+0800 (Singapore Standard Time) {} _f: "YYYY-MM-DD" _i: "2021-12-1" _isAMomentObject: true _isUTC: false _isValid: true _locale: Locale {_calendar: {…}, _longDateFormat: {…}, _invalidDate: 'Invalid date', _dayOfMonthOrdinalParse: /\d{1,2}(th|st|nd|rd)/, ordinal: ƒ, …} _pf: {empty: false, unusedTokens: Array(0), unusedInput: Array(0), overflow: -1, charsLeftOver: 0, …} [[Prototype]]: Object
How would I be able to extract the format "YYYY-MM-DD" that is already existing in this object that is shown in the console.log?