Use express, moment, moment-timezone const moment = require('moment-timezone'); app.get('/moment', (req, res) => { const datestr = '2020-07-01'; res.status(200).json({ local_offset: moment(datestr).utc(), local_unix: moment(datestr).unix(), zone0_unix: moment(datestr).zone(0).unix(), zone8_unix: moment(datestr).zone(8).unix(), timezone0_unix: moment.tz(datestr, 'GMT').unix(), timezone8_unix: moment.tz(datestr, 'Asia/Taipei').unix(), }); }); // No use, just for keep function dateForTimezone(offset, d) { // Copy date if supplied or use current d = d? new Date(+d) : new Date(); // Use supplied offset or system offset = offset || -d.

繼續閱讀

作者的圖片

Sue boy

Sueboy Can support You

CIO

Taiwan