在 ionic 2 项目中使用 moment.js 包 [英] using moment.js package in ionic 2 project
问题描述
我想在 Moment.js 包中使用我的项目 ionic 2 中的日期,但我不知道该怎么做这是链接
检查这个 link 用于打字稿.
1 - 通过 NPM 安装:
npm install moment -S
2 - 在您的 Typescript 文件中导入:
从'moment'导入时刻;
3 - 在您的 Typescript 文件中使用:
let data = moment().format('YYYYMMDD');让时间 = moment().format('HHmmss');console.log('今天是:',数据+'和时间:',时间);
希望对你有所帮助.:)
编辑:仍然适用于 Ionic v3.9.2 (2018-03-08)
i want to use in Moment.js package for dates in my project ionic 2 and i'm not sure how to do that this is the link moment js link
i have datetime variable and i want that to be from my zone area. should i do that? because it's in javascript and ionic 2 use in typescript
i tried to do it but it's not works
constructor(public navCtrl: NavController,private platform:Platform) {
mydate=new Date();
mydate=moment.moment().format('MMMM Do YYYY, h:mm:ss a');
}
when i try to use this
let data = moment().format('YYYYMMDD');
let time = moment().format('HHmmss');
console.log('today is: ', data + ' and time: ', time);
i get this errror
Check this link for typescript.
1 - Install via NPM:
npm install moment -S
2 - Import in your Typescript file:
import moment from 'moment';
3 - Use in your Typescript file:
let data = moment().format('YYYYMMDD');
let time = moment().format('HHmmss');
console.log('today is: ', data + ' and time: ', time);
I hope to have been a help to you. :)
EDIT: Still works fine with Ionic v3.9.2 (2018-03-08)
这篇关于在 ionic 2 项目中使用 moment.js 包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!