8

I am using p-calendar

I would like all past dates to be disabled

here is what I have :

 <p-calendar formControlName="date" [inline]="true" tabindex="0" [disabledDates]="invalidDates" [disabledDays]="[0,6]"></p-calendar>

This is not working, what do I need to change to get the result I want ?

The Dead Man
  • 6,258
  • 28
  • 111
  • 193

1 Answers1

12

The calendar has a minDate input. Just set it to the current date, that way it cannot be lower than today.

In the code:

minimumDate = new Date();

In the template:

<p-calendar formControlName="date" [inline]="true" [minDate]="minimumDate" tabindex="0" [disabledDates]="invalidDates" [disabledDays]="[0,6]"></p-calendar>
user184994
  • 17,791
  • 1
  • 46
  • 52
  • If date editing is present, editing the date to a past date, allows choosing past date. – karthi Oct 25 '19 at 06:38
  • Is there anything for Time also? Lets say right now its is 14:00 hrs and want to prevent the user from selecting anything before this 14:00 hrs not even 13:59 hrs. Please help. I didnt find anything for mintime. – Tanzeel Jul 30 '22 at 06:32