.tz is not a function
See original GitHub issueDescribe the bug Trying to use the timezone plugin but getting .tz() is not a function error.
Information
- 1.9.8
- React Native (Android)
- America/Vancouver
Setup
import dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc';
import timezone from 'dayjs/plugin/timezone';
dayjs.extend(utc);
dayjs.extend(timezone);
console.log(dayjs().tz('America/Vancouver'))
Error
[Wed Feb 10 2021 09:51:03.304] ERROR TypeError: (0, _dayjs.default)().tz is not a function. (In '(0, _dayjs.default)().tz('America/Vancouver')', '(0, _dayjs.default)().tz' is undefined)
Issue Analytics
- State:
- Created 3 years ago
- Reactions:10
- Comments:11 (1 by maintainers)
Top Results From Across the Web
TypeError: moment().tz is not a function - Stack Overflow
When testing using jasmine, I am getting this error. TypeError: moment.tz is not a function.
Read more >Uncaught TypeError: Moment(...).tz is not a function at ... - GitHub
When I try running moment().tz('America/Chicago').format('M') I get the uncaught error. moment.version "2.19.2" moment() ...
Read more >TypeError: moment.tz is not a function at new SfTimestamp
TypeError: moment.tz is not a function at new SfTimestamp ... It appears to be an issue with the way sf_timestamp.js is using moment...
Read more >moment/moment-timezone - Gitter
I am getting error: moment().tz is not a function. I am importing moment using es6 modules, do I need import time zone too?...
Read more >JavaScript : TypeError: moment().tz is not a function - YouTube
JavaScript : TypeError: moment(). tz is not a function [ Gift : Animated Search Engine : https://bit.ly/AnimSearch ] JavaScript : TypeError: ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

The extend method only extends the class in the scope of the current file. When you then import dayjs again in another file you get the un-extended version. To get around this do something similar to @madhurgarg71. I use something like this in a date-utils.ts file:
Then everyplace else in my application I use something like:
You have to import and extend in every file that you want to use the plug-ins