I\'m working with ngbDatepicker this is giving me JSON date format like:
{ year: 2019, month: 6, day: 9 }
How can I convert this into YYYY/
if you are using date field you need to bind the model in ts. in the html, call the method dateselect like this
(dateSelect)="onDateSelect($event)"
Full code:
In the type script, use the following code.This is applicable only if you are using Ngbdate picker.
onDateSelect(event) {
let year = event.year;
let month = event.month <= 9 ? '0' + event.month : event.month;;
let day = event.day <= 9 ? '0' + event.day : event.day;;
let finalDate = year + "-" + month + "-" + day;
}