Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable past date in owl-date-time picker in angular 5

Tags:

angular

I am using owl-date-time picker from angular 5. When I select today date from picker, it should not show past date and month.

Code:

<div class="form-group">
 <label class="control-label col-sm-2 date-right-padding">Date</label>
  <div class="col-sm-5 datePickerField no-left-padding">
   <input [owlDateTime]="createTaskDatePicker" maxlength="19" 
    [disabled]="isDateEnabledCreateTask" 
    [(ngModel)]="createTask.activationDate" placeholder="dd/MM/yyyy hh:mm" 
    class="form-control owl-date-time-input" name="createTaskDate" 
    (click)="clearCreateTaskErrorMessages()">
   <owl-date-time #createTaskDatePicker></owl-date-time>
 </div>
 <div class="col-sm-1 datePickerIcon">
 </div>
</div>

Note:

Past date should be disable, when user select current date.

Question:

How to disable past date in owl-date-time picker.

Your suggestion helpful for me.

like image 444
RanjithKumar SV Avatar asked Dec 08 '22 14:12

RanjithKumar SV


1 Answers

  • Add current date in component first:

    public todayDate:any = new Date();
    
  • Then add below attribute to html input:

    [min]="todayDate"       
    
like image 135
Niraj Karmick Avatar answered Dec 28 '22 08:12

Niraj Karmick