Ionic 3 模拟器和 Firefox 的 Typescript 日期无效 [英] Typescript Invalid date with Ionic 3 simulator and Firefox

查看:33
本文介绍了Ionic 3 模拟器和 Firefox 的 Typescript 日期无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MomentJs 有这个功能

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");
          }

我得到了这个结果:晚上 7:39我想这样显示它 19:39

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

推荐答案

我强烈推荐使用 momentJs 与您的 Ionic 3 应用程序一起使用.这样您就不会像现在这样遇到任何特定于浏览器的错误.

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

npm 安装时刻

.ts

import moment from 'moment';

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

更新:

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

这篇关于Ionic 3 模拟器和 Firefox 的 Typescript 日期无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆