Struggling to get ion-datetime min & max working correctly



I’m struggling to get the ion-datetime component working correctly.

My issue is with setting the min and max values.

The error I get is the following:
caused by: Cannot read property ‘year’ of null

What is the correct date format to enter for min and max?

Are min and max meant to be used like [min]="" or min="{{…}}"



The docs say ISO-8601.


So I’ve set the time as per ISO-8601 and while I dont get the error, it still doesnt respect my minimum.


Any ideas?


I believe if you set a min, you must also specify a max (and a starting point in between the two somewhere). The following seems to work for me:

dt: string = "2017-07-01";

<ion-datetime [(ngModel)]="dt" min="2017-04-23" max="2020-10-10"></ion-datetime>


Thanks :slight_smile:

That got me sorted.


I am new to ionic framework and trying to use ion-datetime in ionic2.

I have two ion-datetime fields in my page ,one is start date and other is end date to show energy consumption graphs. start date should be set to current month first date(Ex: if current month is june 01-06-2017,if july 01-07-2017 …) and end date should be set to today. I am done with End date,but I am stuck with setting start date as month first date dynamically… Expecting some immediate help.
Thanks in advance!