TypeError: moment().tz is not a function

后端 未结 5 1006
Happy的楠姐
Happy的楠姐 2021-01-01 08:26

When testing using jasmine, I am getting this error.

TypeError: moment.tz is not a function

My code that I try to test is

l         


        
5条回答
  •  暖寄归人
    2021-01-01 08:44

    For Node.js, According to the original documentation: moment js documentation

    You should do

    npm install moment-timezone
    

    Then use it like this

    var moment = require('moment-timezone');
    moment().tz("America/Los_Angeles").format();
    

提交回复
热议问题