How to set default time of ion-datetime?

穿精又带淫゛_ 提交于 2020-01-06 06:07:12

问题


I am trying to set the default time of this datetime picker to 0800. Any idea how i can do this?

<ion-label floating>Time: From</ion-label>
          <ion-datetime displayFormat="HH:mm" pickerFormat="HH:mm" [(ngModel)]="request.from" ></ion-datetime>

回答1:


try something like :

<ion-item>
  <ion-label>Date</ion-label>
  <ion-datetime displayFormat="MM/DD/YYYY" [(ngModel)]="myDate"></ion-datetime>
</ion-item>

JS:

$scope.myDate = "2017-08-08 11:22:00";



回答2:


In my case, I'll receive the wrong date format from the DB side. So, will change to the below formate. and it will work like other normal variables no extra settings or anything will be required for that.

<ion-item>
  <ion-label>Date</ion-label>
  <ion-datetime displayFormat="MM/DD/YYYY" [(ngModel)]="myDate"></ion-datetime>
</ion-item>

Date format for ion-datetime must be like:

this.myDate = 2018-12-24T13:03:38.136Z;

So, make sure you are receiving valid date formate.



来源:https://stackoverflow.com/questions/45573590/how-to-set-default-time-of-ion-datetime

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!