Hi All, as per below link in Ionic V6, ion-datetime makes no assumption about local times. We must pass into the model as the local time we want.
My question is can anyone help me find a clean way to pass UTC time as local time into the picker?
I think I know how to then convert back to UTC using the example in the ionic documents.
Example of UTC time I am working with:
2021-12-16T18:54:00+00:00
For the purpose of the example I use moment to convert to and from local time:
eg
moment(testDate).local();
<ion-item class="ion-text-wrap" button="true" id="ionic-date-contact-start">
<ion-icon name="calendar" slot="start"></ion-icon>
<ion-label style="color:#424242">Start Date</ion-label>
<ion-text>{{testDate|date:'mediumDate'}}</ion-text>
<ion-popover trigger="ionic-date-contact-start" show-backdrop="false">
<ng-template>
<ion-datetime
#popoverDatetime
presentation="date"
[(ngModel)]="testDate"
(ionChange)="testDate = formatDate(popoverDatetime.value)"
[showClearButton]="true"
></ion-datetime>
</ng-template>
</ion-popover>
</ion-item>
formatDate(value) {
return moment(value);
}
1 post - 1 participant