How to set ionic datetime default picking date without forcing it to be initially displayed?

Hi,
Does anyone know how can I set the default value in datetime, like making it today forexample? Ionic sets it by default value/placeholder to the maximum date value which doesn’t make sense. I just want that when the user clicks to pick an option to find the default value/place holder that I set.

I tried binding the date to today’s date but then it automatically fills the date field with today’s date. But what if I want to leave it blank until the user chooses a date.

Thanks for your support

Declare a variable in your component

this.startDate = new Date().toISOString();

and in your html

<ion-datetime
      displayFormat="MMM DD, YYYY HH:mm"
      [(ngModel)]="startDate"
       >
</ion-datetime>
1 Like

Thanks for your reply, but this doesn’t solve the problem as it forces today’s days to be displayed in the field by default… I would like to leave it blank until the user enters a date

Ahh I misread it,
try this:

this.startDate = null;

Again sets the default date in the picking options to the maximum :confused: It doesn’t show today’s date anymore…

Hmmm I’m not sure how to handle this.

If I understood corectly, you want the value in the picker to be blank, but when you open the picker you want it to be set to todays date?

Yup exactly that’s what I meant.
To todays date or to any value which makes sense but not automatically to the maximum date in 2030 forexample… then the user has to scroll down all the way. Just as an initial value to start scrolling from

Hmm this functionality is related to this github issue.

Hello, I have the same problem now in Ionic 5. I submitted a PR on this that solves our problem:

Maybe comment on it or react so it gets noticed more and gets merged soon? TIA