angular - Ionic 2 Moment JS with Moment TimeZones -
i'm working on using moment.js typescript. ran following commands
npm install moment-timezone --save npm install @types/moment @types/moment-timezone --save but reason in formattime function, moment undefined. i'm not getting errors ide regarding import of moment , can see both moment , moment-timezone in npm folder. i've been crawling through post i'm not seeing helpful information. appreciated
import moment 'moment'; export class utils { text: string; constructor() { console.log('hello utils component'); } //this function take time in ms , timezone , coverts //@params time - time in milliseconds //@params tz - timezone //@paramz iszoneabbr - true if zone abbr should displayed //@return - return formattedtime public formattime(time, tz, iszoneabbr): string { console.log(json.stringify(moment)); return ""; // var formattedtime = moment.tz(time, tz); // if (iszoneabbr) { // return formattedtime.format('h:mm z'); // } // return formattedtime.format('h:mm a'); }; }
you have reference moment-timezone , not moment because not moment package
import * momenttz 'moment-timezone';
Comments
Post a Comment