moment-timezone icon indicating copy to clipboard operation
moment-timezone copied to clipboard

utcOffset function is not working at CentOS 7

Open KyouhyunHwang opened this issue 6 years ago • 1 comments

I tested as below at Ubuntu 16 and CentOS 7.3 to get utc offset.

const moment = require('moment-timezone'); const timezoneName = moment.tz.guess(); const timezone = moment.tz.zone(timezoneName); const now = Date.now(); console.log(timezone.utcOffset(now));

It worked well at Ubuntu. But timezone.utcOffset(now) returned error at CentOS as below.

TypeError: timezone.utcOffset is not a function at Object. (/opt/pcn/test.js:8:22) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3) at Module.runMain (module.js:604:10) at run (bootstrap_node.js:394:7) at startup (bootstrap_node.js:149:9) at bootstrap_node.js:509:3

And timezone.offset(now) worked well without any deprecation message.

KyouhyunHwang avatar Mar 06 '18 07:03 KyouhyunHwang

Doesn't seem to work for me on Mac OS either.

I literally copied and pasted this from the moment-timezone website

moment.tz.zone('America/Los_Angeles').utcOffset(1403465838805)

But the error is that the function utcOffset does not exist.

Got this example from another ticket: moment.tz('2026-07-27', 'Europe/Zurich').utcOffset() which does seem to work fine. The online example is just out of date I guess

matthijn avatar Aug 15 '18 14:08 matthijn

I'm closing off stale issues as they're very difficult to reproduce, and this project is now in maintenance-only mode. Try upgrading to the latest version of Moment Timezone, but feel free to open a new issue if this is still a problem.

gilmoreorless avatar Jan 28 '23 11:01 gilmoreorless