Datetime, set time min and max

Hi,
how to set datetime with min and max for time
I am able to set min max for date but not for time
<ion-datetime displayFormat=“MMM DD, YYYY HH:mm” min="{{myDate}}" [(ngModel)]=“myDate”>
I want to set min time to current time and
time should be in the range of 10am to 8pm on any selected date.

This is mention in the DateTime docs, so please check that out.

I know, I checked and tried it but its not working
I can set min date but not time.
can you show me example plz.

Well, as a note (not a solution) it doesn’t natively validate time (hope it changes in a while) but only year, month and day as you may see in [source here] (https://github.com/driftyco/ionic/blob/master/src/components/datetime/datetime.ts#L574-L576)

Hi there Vinodhumm
Maybe a solution to solve this is hourValues

<ion-datetime displayFormat="h:mm A" pickerFormat="h:mm:A" hourValues="07,08,09,10,11,12,13,14,15,16,17,18,19,20">

like this

1 Like

i am using below code how to set min and max date

<ion-input formControlName="LastPayDate" mindate="12/02/2016" type="date"></ion-input>

I have a usecase : the user should not able to select 8am but should be able to select 8pm.If i follow this user can select both 8am and 8pm.

2 Likes

To be short, there’s no way to to do that with the ionic <ion-datetime> i sugest you look for the Native datepicker Or some plugin, for that specific case i really suggest to create the date time component.