I am trying to set a min and max date within PrimeNG's . I would like for the "FROM DATE" input to not be older than 2 weeks from today's date. And the "TO DATE" input to not be more than 1 year away from today's date.
Here are my date fields.
<p-calendar [showIcon]="true" [minDate]="minDate" [readonlyInput]="true" placeholder="From Date" id="setter" ></p-calendar>
<p-calendar [showIcon]="true" [maxDate]="maxDate" [readonlyInput]="true"placeholder="To Date" id="setter"></p-calendar>
This is in my logic in the .ts file
ngOnInit() {
let today = new Date();
let month = today.getMonth();
let year = today.getFullYear();
let prevMonth = (month === 0) ? 11 : month -1;
let nextMonth = (month === 11) ? 0 : month + 4;
this.minDate = new Date();
this.maxDate = new Date();
this.minDate.setMonth(prevMonth);
this.maxDate.setMonth(nextMonth);
}