Select Date and Time in 2 steps using Ionic DateTime: I want to use Ionic DateTime selecting date and time. The problem is that the picker with pickerFormat="DD MMMM YYYY HH:mm" gets complicated and too narrow, so I want to select date first and just after select the time. Any idea about how to do so?
ISO 8601 Datetime Format: YYYY-MM-DDTHH:mmZ Ionic uses the ISO 8601 datetime format for its value. The value is simply a string, rather than using JavaScript's Date object. Using the ISO datetime format makes it easy to serialize and parse within JSON objects and databases.
Adding Datepicker in Ionic 6 Template We use the ion-datetime component to add datepicker in Ionic app. Ionic date picker comes on the screen from the bottom of a page. You can separately choose Month, Date, Year, Hours and Minutes directly from scrollable columns which makes it great from the UX perspective.
ISO 8601 Datetime Format: YYYY-MM-DDTHH:mmZ Ionic uses the ISO 8601 datetime format for its value. The value is simply a string, rather than using JavaScript's Date object.
You can always separate them like this
<ion-item [hidden]="!!myDate">
<ion-label>Date</ion-label>
<ion-datetime (ngModelChange)="change(datePicker)" displayFormat="MM/DD/YYYY" [(ngModel)]="myDate"></ion-datetime>
</ion-item>
<ion-item [hidden]="!myDate" >
<ion-label>Time</ion-label>
<ion-datetime #datePicker
(ionCancel)="myDate=undefined" displayFormat="HH:mm" [(ngModel)]="myTime"></ion-datetime>
</ion-item>
<h1 [hidden]="!myTime">result is {{myDate}} : {{myTime}} </h1>
then in ts
change(datePicker){
datePicker.open();
}
Then concatenate the results
this.dateTime= this.myDate + ":" + this.myTime;
Here's a DEMO
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With