I need a certain case that, I have time scope from today day end to tomorrow day start.
Let, the scope is today 21 to tomorrow 2 (24 hours format)
So, If the minDate on today at 21 o'clock and the maxDate on the next day at 2 o'clock, then the calendar timeOnly component does not give to select a time for the next day like, 1 or 2 o'clock.
component.html
Code: Select all
<p-calendar
[timeOnly]="true"
[(ngModel)]="date"
[defaultDate]="initialDate"
[minDate]="minDate"
[maxDate]="maxDate"
[hourFormat]="24"
[stepMinute]="15"
></p-calendar>
Code: Select all
export class AppComponent {
date: Date;
initialDate: Date;
minDate: Date;
maxDate: Date;
ngOnInit() {
this.initialDate = new Date();
this.initialDate.setHours(21, 0, 0, 0);
this.minDate = new Date();
this.minDate.setHours(20, 59);
this.maxDate = new Date();
this.maxDate.setDate(this.initialDate.getDate() + 1); //next day
this.maxDate.setHours(2, 0); // at 2 AM
}
}
https://stackblitz.com/edit/primeng-cal ... mponent.ts