[Node.js] 使用moment-timezone處理時區

安裝moment及moment timezone

npm install moment --save
npm install moment-timezone --save
const moment = require ('moment');
const tz = require('moment-timezone');

const timeString = "2019-04-07 02:00:00";
let timezone = "Asia/Tokyo";
let now = moment(timeString,'YYYY-MM-DD hh:mm:ss');
let utcTime = moment(timeString).utc();
let jpTime = moment(timeString,'YYYY-MM-DDThh:mm:ss').tz(timezone);
let jpTimeTz = moment.tz(timeString,'YYYY-MM-DDThh:mm:ss',timezone);
console.log(now);
console.log(utcTime);
console.log(jpTime);
console.log(jpTimeTz);