Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError: dayjs.utc is not a function

I am getting this error

dayjs.utc is not a function

Here is my code

const dayjs = require('dayjs')

console.log('utc time',dayjs.utc())
like image 229
Srikanth Avatar asked May 08 '26 00:05

Srikanth


2 Answers

Fix: I tried this it's working:

const dayjs = require('dayjs')
const utc = require('dayjs/plugin/utc')
dayjs.extend(utc)

console.log('utc time',dayjs.utc())

Refer docs https://day.js.org/docs/en/plugin/utc

like image 176
Srikanth Avatar answered May 10 '26 12:05

Srikanth


If you using import:

import dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc';
dayjs.extend(utc)
like image 44
geegog Avatar answered May 10 '26 13:05

geegog



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!