I am getting this error.
TypeError: dayjs(...).tz is not a function
My code is
const dayjs = require('dayjs');
const dayjsAmerica = dayjs("2014-06-01 12:00").tz("America/New_York");
You need to extend the dayjs class with the utc and timezone classes/plugins:
const dayjs = require('dayjs');
const utc = require('dayjs/plugin/utc');
const timezone = require('dayjs/plugin/timezone');
dayjs.extend(utc);
dayjs.extend(timezone);
Refer to docs for more details: https://day.js.org/docs/en/timezone/timezone
this worked also for me as @kandula
npm install dayjs
const dayjs = require('dayjs');
const utc = require('dayjs/plugin/utc');
const timezone = require('dayjs/plugin/timezone');
dayjs.extend(utc); dayjs.extend(timezone);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With