# Format from ionic-datetime keeps changing when selecting a new date

**URL:** <https://forum.ionicframework.com/t/format-from-ionic-datetime-keeps-changing-when-selecting-a-new-date/207326>\
**Category:** Ionic Angular\
**Created:** [March 29, 2021, 2:52pm UTC](https://forum.ionicframework.com/t/format-from-ionic-datetime-keeps-changing-when-selecting-a-new-date/207326 "2021-03-29T14:52:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alpha-Blue](https://avatars.discourse-cdn.com/v4/letter/a/ee59a6/32.png) [@Alpha-Blue](https://forum.ionicframework.com/u/Alpha-Blue)\
**Post date:** [March 29, 2021, 2:52pm UTC](https://forum.ionicframework.com/t/format-from-ionic-datetime-keeps-changing-when-selecting-a-new-date/207326/1 "2021-03-29T14:52:42Z")

</div>

Hi all!

I’ve been struggling with the ionic-datetime component today.

So I have this piece of code in my .html:

```auto
 <ion-item class="container-date" lines="none">
    <ion-datetime displayFormat="DD/MM/YYYY" pickerFormat="DD/MM/YYYY" [(ngModel)]="date" placeholder="{{ date }}"></ion-datetime>
  </ion-item>

```

And the following in my .ts file:

```auto
date = moment(new Date()).format("DD/MM/YYYY");

```

I’ve also tried this; same result though:

```auto
date = new Date().toISOString();

```

So the format before I select a new date is as follows:  
29/03/2021  
When I select a new date (let’s say 30/03/2021) it changes to “2021-03-30” and when I try changing it again it changes to “2021-03-31T00:00:00+02:00”.

I have no clue what to do anymore. Thanks in advance!

FYI, I want to sort date from my local json file using the datetime component. And I need a specific format for that to work.

---

<div class="post-metadata">

**Author:** ![TomCosta](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/tomcosta/32/149715_2.png) [@TomCosta](https://forum.ionicframework.com/u/TomCosta)\
**Post date:** [May 1, 2021, 7:21pm UTC](https://forum.ionicframework.com/t/format-from-ionic-datetime-keeps-changing-when-selecting-a-new-date/207326/2 "2021-05-01T19:21:29Z")

</div>

Hi @Alpha-Blue! 😷  
My suggestion, please try like this.

On .html file:

```auto
<ion-datetime displayFormat="DD/MM/YYYY" pickerFormat="DD/MM/YYYY" [(ngModel)]="date" placeholder="{{ date | date:'dd/MM/yyyy' }}"></ion-datetime>

```

On .ts file:

```auto
date = new Date();

```
