dayjs
dayjs copied to clipboard
How to install utc & timezone plugin?
I don't know how to install specific plugins.
The docs only provide an answer on how to use them, but not on how to install them.
I want to use timezone and utc e.g.
// YARN
yarn add dayjs
// NPM
npm i dayjs
After that you just import and extend
import dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc';
import timezone from 'dayjs/plugin/timezone';
dayjs.extend(utc);
dayjs.extend(timezone);
dayjs.tz.setDefault('Asia/Tokyo');
dayjs.utc().format('YYYY-MM-DD HH:mm:ssZ');
aight, I will try it out. But I did install dayjs with npm install dayjs and the plugins were not found.
This works:
import dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc.js';
import timezone from 'dayjs/plugin/timezone.js';
(note the .js)
I reinstalled dayjs completely which made it work eventually.