I'm currently working with Angular 7 and I'm facing some challenges when it comes to extracting the year, month, and day from a Date type variable. Additionally, I am utilizing Bootstrap 4 in my project. Can anyone assist me with this?
Below is my HTML code:
<div class="form-group">
<label>Check date</label>
<input type="date" id="user1" formControlName="search_date" class="form-control" placeholder="Enter date">
</div>
and the corresponding .ts file snippet:
ngOnInit() {
this.searchForm = this.formBuilder.group({
emp_type: '',
designation: '',
week_month: '',
search_date: Date
});
}
}
var yer = this.searchForm.value.search_date
console.log(yer.getUTCMonth())
As a result, an error message pops up:
TypeError: yer.getUTCMonth is not a function
at HomeComponent.push../src/app/home/home.component.ts.HomeComponent.onsubmit (home.component.ts:53)