npm install moment --save
npm install --save-dev @types/moment-duration-format
npm install --save-dev @types/moment-timezone
declare var $: any;
import * as moment from 'moment-timezone';
import * as moment_duration from 'moment'; // the moment.js in moment-timezone has conflict with monent.js. So I make an alias
import 'moment-duration-format';
import 'moment-timezone';
console.log(moment().format('MMMM Do YYYY, h:mm:ss a'));
console.log(moment('2014-06-01T12:00:00Z').tz('America/Los_Angeles').format('YYYY-MM-DD hh:mm:ss a z'));
console.log(moment(1530466846000).get('year'));
console.log(moment(1530466846000).get('day'));
console.log(moment(1403454068850).tz('America/Toronto').format('YYYY-MM-DD hh:mm:ss a z'));
console.log(moment(1530466846000).tz('America/Los_Angeles').format('YYYY-MM-DD hh:mm:ss a z'));
console.log(moment_duration.duration(123, 'minutes').format());
console.log(moment.unix(1318781876.721).format('YYYY-MM-DD hh:mm:ss a'));
console.log(moment.unix(1318781876).utc().format('YYYY-MM-DD hh:mm:ss a'));
console.log(moment().format());
console.log(moment().utc().format());
console.log(moment().dayOfYear());
console.log(moment().date());
console.log(moment().week());
const a = moment().subtract(1, 'day');
const b = moment().add(1, 'day');
console.log(moment.max(a, b).format());
console.log(moment().add(7, 'days').format());
console.log(moment().local().hours());
console.log(moment().startOf('year').format());
console.log(moment('2016-08-16T00:00:00Z').tz('Asia/Shanghai').format('YYYY-MM-DD hh:mm:ss a z'));
console.log(moment('2016-08-16T00:00:00Z').fromNow().valueOf());
console.log(-moment('2016-08-16T00:00:00Z').unix() + moment().unix());
console.log(moment_duration.duration(-moment('2016-08-16T00:00:00Z').unix() + moment().unix(), 'seconds').format('Y [years], M [months], D [days], H [hrs], m [min], s[s]'));