# A genuine question on when will you guys face the ion-datetime horrible state

**URL:** <https://forum.ionicframework.com/t/a-genuine-question-on-when-will-you-guys-face-the-ion-datetime-horrible-state/235083>\
**Category:** Ionic Angular\
**Created:** [July 24, 2023, 7:44am UTC](https://forum.ionicframework.com/t/a-genuine-question-on-when-will-you-guys-face-the-ion-datetime-horrible-state/235083 "2023-07-24T07:44:41Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![forevermasteryi](https://avatars.discourse-cdn.com/v4/letter/f/58956e/32.png) [@forevermasteryi](https://forum.ionicframework.com/u/forevermasteryi)\
**Post date:** [July 24, 2023, 7:44am UTC](https://forum.ionicframework.com/t/a-genuine-question-on-when-will-you-guys-face-the-ion-datetime-horrible-state/235083/1 "2023-07-24T07:44:41Z")

</div>

Its been 2021 since user of ionic raise up the ion-datetime component problem, the lack of support on such important component shocked me. In here, I would like to raise out the problem, AGAIN, just in case you guys still give a care about user on your framework.

-year/month wheel value emitting

I still don’t know why ionic developer have a tendency to FORCE the component emiting value each time user spinning the year/month wheel. The sole purpose of putting the wheel here is to allow user to SELECT year/month more easily not to CHANGING the whole date. Why would you force a valueChange on such action, can you atleast pays little effort and making it not emitting value each time user spinning the wheel but rather only emitting it when closing the wheel and only changing the year/month, not the day, not the time, not minute, not the second, its a year/month wheel, not a whole datetime wheel for god sake?

Because right now, CHANGING YEAR/MONTH WILL RUINED THE DAY VALUE AND WHY YOU FORCING USER TO HAVE IT ???

-no way of setting calender value programatically

Really, you are making a framework, and user can’t set your component value programatically, really, wow, unbelievable. Come on. Right now you are forced to bind the value to angular variable or else, good luck 🙂 , what that mean? complicated spegahtti if statement thats what you get Im tellling you if you ACTUALLY USE YOUR FRAMEWORK TO DEVELOP SOMETHING

I don’t even know how would you guys one day making this framework profitable, if its made with so called “love”, please stop, I am already knee deep with a project using this framework, don’t ask me to change a framework.

---

<div class="post-metadata">

**Author:** ![aaronksaunders](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/aaronksaunders/32/13729_2.png) [@aaronksaunders](https://forum.ionicframework.com/u/aaronksaunders)\
**Post date:** [July 24, 2023, 9:54pm UTC](https://forum.ionicframework.com/t/a-genuine-question-on-when-will-you-guys-face-the-ion-datetime-horrible-state/235083/2 "2023-07-24T21:54:53Z")

</div>

somebody sounds like they are having a bad day… is there an actual question here somewhere are did you just need to get that off your chest?

---

<div class="post-metadata">

**Author:** ![forevermasteryi](https://avatars.discourse-cdn.com/v4/letter/f/58956e/32.png) [@forevermasteryi](https://forum.ionicframework.com/u/forevermasteryi)\
**Post date:** [July 25, 2023, 10:06am UTC](https://forum.ionicframework.com/t/a-genuine-question-on-when-will-you-guys-face-the-ion-datetime-horrible-state/235083/3 "2023-07-25T10:06:32Z")

</div>

Yes, when will ionic developer seperate the value emits from year/month wheel and day input .

Because right now , the component is barely usable that user input in year/month will instantly emit and ruined the accuracy of the input.

---

<div class="post-metadata">

**Author:** ![forevermasteryi](https://avatars.discourse-cdn.com/v4/letter/f/58956e/32.png) [@forevermasteryi](https://forum.ionicframework.com/u/forevermasteryi)\
**Post date:** [July 25, 2023, 10:07am UTC](https://forum.ionicframework.com/t/a-genuine-question-on-when-will-you-guys-face-the-ion-datetime-horrible-state/235083/4 "2023-07-25T10:07:16Z")

</div>

Also, I still can’t mimick user input programmatically .

Like literally, 0 chance.

---

<div class="post-metadata">

**Author:** ![mirko77](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mirko77/32/137216_2.png) [@mirko77](https://forum.ionicframework.com/u/mirko77)\
**Post date:** [July 27, 2023, 2:35pm UTC](https://forum.ionicframework.com/t/a-genuine-question-on-when-will-you-guys-face-the-ion-datetime-horrible-state/235083/5 "2023-07-27T14:35:17Z")

</div>

That is a lost cause.

For dates and time inputs, we use standard HTML directly and never used the Ionic components as we always had issues, since Ionic 1.

For some specific cases, we use the Cordova plugin [cordova-wheel-selector-plugin](https://github.com/jasonmamy/cordova-wheel-selector-plugin)  
to show a hh:mm:ss or DD/MM/YYYY wheel.

---

<div class="post-metadata">

**Author:** ![ldebeasi](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/ldebeasi/32/147501_2.png) [@ldebeasi](https://forum.ionicframework.com/u/ldebeasi)\
**Post date:** [July 27, 2023, 3:54pm UTC](https://forum.ionicframework.com/t/a-genuine-question-on-when-will-you-guys-face-the-ion-datetime-horrible-state/235083/6 "2023-07-27T15:54:51Z")

</div>

Hey there! I’m the lead engineer on Ionic Framework and have worked pretty extensively on `ion-datetime`, so I’ll do my best to address your concerns.

I can confirm that the the value changing when the month/year picker changes is an intentional behavior. Ionic Framework is designed to follow what the native iOS and Material Design components do. The native iOS date picker also changes the value when the month/year picker changes which is why we opted to follow that behavior.

I attached a sample of this same behavior happening with the native iOS date picker:

![Simulator Screen Recording - iPhone SE (3rd generation) - 2023-07-27 at 11.44.43](https://global.discourse-cdn.com/ionicframework/original/3X/1/d/1d5572b4b14f0af57dc738742132080e89571b18.gif)

We do also give the option to customize this behavior using the [showDefaultButtons](https://ionicframework.com/docs/api/datetime#showing-confirmation-buttons) property. This property allows you to require explicit user confirmation before the `ion-datetime` value changes. I think this is probably what you want as it prevents `ionChange` from being emitted every time the month/year changes. Instead, `ionChange` only emits once users press the “Confirm” button.

---

<div class="post-metadata">

**Author:** ![ldebeasi](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/ldebeasi/32/147501_2.png) [@ldebeasi](https://forum.ionicframework.com/u/ldebeasi)\
**Post date:** [July 27, 2023, 3:59pm UTC](https://forum.ionicframework.com/t/a-genuine-question-on-when-will-you-guys-face-the-ion-datetime-horrible-state/235083/7 "2023-07-27T15:59:30Z")

</div>

> [@forevermasteryi](#):
>
> -no way of setting calender value programatically

You can absolutely set the value of `ion-datetime` programmatically. There are two things to note about this:

1. Asynchronously setting the value of `ion-datetime` does not re-render the UI. This is being tracked in [bug: Setting ion-datetime value programatically does not update the grid · Issue #26391 · ionic-team/ionic-framework · GitHub](https://github.com/ionic-team/ionic-framework/issues/26391), and it is something we are actively working on correcting. In fact, we have a PR to fix this that is currently being reviewed by the team: [fix(datetime): scroll to newly selected date when value changes by amandaejohnston · Pull Request #27806 · ionic-team/ionic-framework · GitHub](https://github.com/ionic-team/ionic-framework/pull/27806)

2. Programmatically setting the value of `ion-datetime` does not emit `ionChange`. `ionChange` only emits as a result of user interaction, so emitting `ionChange` for programmatic changes isn’t really helpful since you already know when the value has changed. This behavior also aligns with how the web’s `<input type="date" />` element works.

---

<div class="post-metadata">

**Author:** ![forevermasteryi](https://avatars.discourse-cdn.com/v4/letter/f/58956e/32.png) [@forevermasteryi](https://forum.ionicframework.com/u/forevermasteryi)\
**Post date:** [July 28, 2023, 3:35am UTC](https://forum.ionicframework.com/t/a-genuine-question-on-when-will-you-guys-face-the-ion-datetime-horrible-state/235083/8 "2023-07-28T03:35:01Z")

</div>

Very well reply. Im very happy to see that even the lead developer have to work pretty extensively on ion-datetime.

> [@ldebeasi](#):
>
> Asynchronously setting the value of `ion-datetime` does not re-render the UI. This is being tracked in [bug: Setting ion-datetime value programatically does not update the grid · Issue #26391 · ionic-team/ionic-framework · GitHub](https://github.com/ionic-team/ionic-framework/issues/26391), and it is something we are actively working on correcting. In fact, we have a PR to fix this that is currently being reviewed by the team: [fix(datetime): scroll to newly selected date when value changes by amandaejohnston · Pull Request #27806 · ionic-team/ionic-framework · GitHub](https://github.com/ionic-team/ionic-framework/pull/27806)

This is exactly what I was talking about.

“Asynchronously setting value” does not re-render the UI. That’s very frustrating. Good to know it is still in the code reviewing phase.

> [@ldebeasi](#):
>
> I can confirm that the the value changing when the month/year picker changes is an intentional behavior. Ionic Framework is designed to follow what the native iOS and Material Design components do. The native iOS date picker also changes the value when the month/year picker changes which is why we opted to follow that behavior.

This makes the component impossible to make a single calender for day range selection, bug-free.

Reason: You can’t seperate whether or not the user want to only change the year/month only, or they want a new day.

Problem :  
You try to make the day-range selection more convineient so you make any value smaller then last input becomes from date and any value bigger then last input become to date.

user accidently scroll to year 3000 and now they have to press the reset button to reset the whole component because your component is too convinient.

> [@ldebeasi](#):
>
> We do also give the option to customize this behavior using the [showDefaultButtons](https://ionicframework.com/docs/api/datetime#showing-confirmation-buttons) property. This property allows you to require explicit user confirmation before the `ion-datetime` value changes. I think this is probably what you want as it prevents `ionChange` from being emitted every time the month/year changes. Instead, `ionChange` only emits once users press the “Confirm” button.

Not ideal solution, This mean you are forced to make user click confirm. This is not intuitive.

For example :

- If you have 10 ion-datetime to pick from you have to click confirm 10 times
- if datetime picker is inside an ion-modal(contact list/ filter etc) you click confirm multiple times. Even worse if you put ion-datetime as a modal itself.

Suggestion. Just make an option to seperate the year/month wheel selection as a boolean property in component html.

So then Ion-datetime will cache the year/month value somewhere. And only emits the value when user click on a day. `[cacheYearMonth]==true`.

Instead of automatically select the same day but different year/month and then emit the value.

This actually in return makes day-range in a single calender possible.

Like trust me, I have sink 200 hours trying to make this work.

---

<div class="post-metadata">

**Author:** ![ldebeasi](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/ldebeasi/32/147501_2.png) [@ldebeasi](https://forum.ionicframework.com/u/ldebeasi)\
**Post date:** [July 28, 2023, 1:12pm UTC](https://forum.ionicframework.com/t/a-genuine-question-on-when-will-you-guys-face-the-ion-datetime-horrible-state/235083/9 "2023-07-28T13:12:45Z")

</div>

> This makes the component impossible to make a single calender for day range selection, bug-free.

`ion-datetime` was not built for range selection so I don’t recommend using `ion-datetime` for this. I have seen some developers use multiple datetime instances (one for the start date and one for the end date), so you could try that. But I’m not surprised you are running into issues using it for range selection since it was not built for that purpose.

We have an open feature request for adding this that you can upvote: [feat: ion-datetime with date range · Issue #23572 · ionic-team/ionic-framework · GitHub](https://github.com/ionic-team/ionic-framework/issues/23572)

* * *

As a best practice, developers should not care about the user changing the month and year or any intermediary steps when using the full grid picker, so I’m not sure I fully understand what you are trying to accomplish with your current usage.

Changing the month/year changes the selected date which matches the behavior that you will find in most native iOS applications. For example, if the selected date is “August 2, 2023” and the user changes the month to “September”, then the selected date emitted will be “September 2, 2023”.

> Suggestion. Just make an option to seperate the year/month wheel selection as a boolean property in component html.

You can already do this using the [`presentation` property](https://ionicframework.com/docs/api/datetime#presentation).

---

<div class="post-metadata">

**Author:** ![ferreirajose](https://avatars.discourse-cdn.com/v4/letter/f/94ad74/32.png) [@ferreirajose](https://forum.ionicframework.com/u/ferreirajose)\
**Post date:** [September 3, 2024, 7:46pm UTC](https://forum.ionicframework.com/t/a-genuine-question-on-when-will-you-guys-face-the-ion-datetime-horrible-state/235083/10 "2024-09-03T19:46:29Z")

</div>

Taking advantage of this conversation, I would like to know if there is any way to add new attributes to the DatetimeHighlight type, for example a border?

Like this:

export type DatetimeHighlightStyle = {  
textColor: string;  
backgroundColor?: string;  
border?: string  
} | {  
textColor?: string;  
backgroundColor: string;  
border?: string;  
};

This would be very useful, as it would solve a problem I am trying to solve when customizing the calendar.

below is the prototype

 ![calendar](https://global.discourse-cdn.com/ionicframework/original/3X/3/6/3683b5e563aaad99d655eb16e0c5a359cfa6f64a.jpeg)

---

<div class="post-metadata">

**Author:** ![ferreirajose](https://avatars.discourse-cdn.com/v4/letter/f/94ad74/32.png) [@ferreirajose](https://forum.ionicframework.com/u/ferreirajose)\
**Post date:** [September 5, 2024, 12:48am UTC](https://forum.ionicframework.com/t/a-genuine-question-on-when-will-you-guys-face-the-ion-datetime-horrible-state/235083/11 "2024-09-05T00:48:01Z")

</div>

@ldebeasi

Taking advantage of this conversation, I would like to know if there is any way to add new attributes to the DatetimeHighlight type, for example a border?

Like this:

export type DatetimeHighlightStyle = {  
textColor: string;  
backgroundColor?: string;  
border?: string  
} | {  
textColor?: string;  
backgroundColor: string;  
border?: string;  
};

This would be very useful, as it would solve a problem I am trying to solve when customizing the calendar.
