Typescript Invalid date with Ionic 3 simulator and Firefox

假装没事ソ 提交于 2020-01-05 04:10:09

问题


I have this function with MomentJs

      CreateFormat(date: string, time: string): string {
            let now = moment(date + " " + time, "YYYY-MM-DD H:m:s z").toDate();
            return moment(now, "YYYY-MM-DD H:m:s z").format("HH:mm");
          }

I got this result : 7:39 pm i want to display it like this 19:39


回答1:


I highly recommend using momentJs with your Ionic 3 app.Then you won't have any browser specific errors like you have now.

npm install moment

.ts

import moment from 'moment';

let now = moment().format('LLLL');

Update:

 moment("02:00 PM", "h:mm A").format("HH:mm")  // "14:00"



回答2:


You can do like this ` {{start_timestamp | date:'HH:mm a'}}




回答3:


in ts file start_timestamp = 1500536460;

print like this in html <p class="timeLabel">{{start_timestamp | date:'YYYY-MM-DD H:m:s z'}}</p>



来源:https://stackoverflow.com/questions/45796498/typescript-invalid-date-with-ionic-3-simulator-and-firefox

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