How to disable past time in owl date timer in angular

943 Views Asked by At

I'm using owl date time for giving the time picker option to a form. But I'm facing a problem with restricting users to select past times, for eg if the current time is 16:15 pm I want to restrict users to save time ie less than the current time 16.15pm.

I tried using [min] attribute but no success.*

code:

<mat-form-field [owlDateTimeTrigger]="dt2" id="timer-clock" floatLabel="never">
              <input placeholder="hh:mm:ss" 
                     matInput 
                     formControlName="form_time"
                     [min]="minTime"
                     [owlDateTimeTrigger]="dt2"  
                     [owlDateTime]="dt2" 
                     [readonly]="true" />

              <owl-date-time [pickerType]="'timer'" 
                             [showSecondsTimer]="true" #dt2 >
              </owl-date-time>

           </mat-form-field>
1

There are 1 best solutions below

1
Nitika On

It depends more on what value you're providing to min, try something like: [min] = 'initialStartDate' where const initialStartDate = new Date(); Notice that min will only accept Date values.