Problem setting min and max for the new datetime comp


i’m trying to dynamically set the min and max values for the v6 datetime component.

If i use viewchild

<ion-datetime #datePicker size="cover" presentation="time" hourCycle="h23" [(ngModel)]="time"></ion-datetime>

 @ViewChild('datePicker') datePicker: IonDatetime;


I get TypeError: Cannot set properties of undefined (setting ‘min’)

And if i use

  <ion-datetime size="cover" presentation="time" hourCycle="h23" [(ngModel)]="time" min="min" max="max"></ion-datetime>

  min: string = "2021-12-20T13:00";
  max: string = "2021-12-20T23:59";

I get Cannot destructure property ‘month’ of ‘parseDate(…)’ as it is undefined.

I there a way to set these properties ? It was working with the prev datetime comp

Thank you

Update here :slight_smile:

I tried this

<ion-datetime size="cover" [min]="min" [max]="max"></ion-datetime>

  min = "2021-12-20T11:00";
  max = "2021-12-22T23:00";

It gave no error but but the results are not those set

kind of same problem here, the difference is that my datetime is not working at all, when I change the tabs of months it doesn’ change or just stop at half away, and the ionChange is not working as the example said

I made it working setting values on init instead of constructor

  ngOnInit() { 

But i think there is a glitch when you set hours in min or max

For exemple here, we should have 11,12,13,…,23 as selectable hours for the first day.

Instead of that, i have 00,01,02,…,11,23

It removed hours from 12 to 22 instead of 00 to 10

If i set min = 2021-12-20T15:01:32.745Z
Then it works but show time to incorrect format => 3 to 11 instead of 15 to 23

Case 1 : bad format + minutes not displaying

Case 2 : bad format

Case 3 : bad format + minutes stays with a minimal 29 even when hour is changed

Pls fix it in next version, for now, min and max are unusable with time picker

1 Like

Any update on this?
Still suffering with the same issue

Saw this in 6.0.4

  • datetime: datetime locale with h23 will respect max time range (#24610) (5925e76), closes #24588