Angular & PrimeNg Datepicker (p-calendar): Disable future dates

Discussão em 'Angular' iniciado por LaCodeM, Agosto 16, 2025.

  1. LaCodeM

    LaCodeM Guest

    I am trying to use primeNG datepicker to select the dates and I need to disable all the future dates (not including today) except the [maxDate] input is not working, actually if I apply it it disables all the dates.

    I have read the documentation and all the related / similar questions on StackOwerflow the problem maybe comes from the fact that I use NgModel but unfortunately I have no other choice than to use it!

    I have also tried to define min and max dates but if I define min date like this:

    minDate = new Date(1900, 0, 1)


    It still disables all the dates...

    My code:

    maxDate = new Date()


    <p-calendar
    [(ngModel)]="dateSince"
    [showIcon]="true" inputId="icon"
    [maxDate]="maxDate"></p-calendar>


    I have tried different formatting of the date even with momentJS but I always get the error that String is not assignable to Date even after I use .toISOString() I have tried even to define disabledDates but this is also not working.

    Version of the PrimeNg is: "^12.0.0" (also I can't modify this)

    Thanks

    Continue reading...

Compartilhe esta Página