本文介紹了ionic 2 ion-datetime ISO 格式問題的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我正在使用 ion-datetime 作為我的預約表格.插入時工作正常,沒有任何問題.但是當我需要從后端更新插入的約會日期表單詳細信息時,日期值不會顯示在 ion-datetime 中.
I am using ion-datetime for my appointment form. While inserting it is working fine without any problem. But when I need to update the inserted appointment date form details from back end, the date value is not displaying in ion-datetime.
下面是我的代碼:
update.html:
<ion-item class="border-bottom">
<ion-label class="ionselect" >Appointment Date:</ion-label>
<ion-datetime name="appdate" displayFormat="YYYY MMM DD" [(ngModel)]="leadDetailsUpdate.appt_date"></ion-datetime>
</ion-item>
update.ts:
leadDetailsUpdate={
appt_date:''
};
我從后端得到的日期格式如下:appt_date: "2017-01-01"
The Date format I am getting from back end as follows:
appt_date: "2017-01-01"
以下是我在控制臺中收到的錯誤消息:
Below is the error message I am getting in console:
解析日期錯誤:null".請提供有效的 ISO 8601 日期時間格式:https://www.w3.org/TR/NOTE-datetime
推薦答案
轉成ISO格式再顯示
var date = new Date('2017-01-01').toISOString()
console.log(date)
這篇關于ionic 2 ion-datetime ISO 格式問題的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!