Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nuxt 3 - dayJs(...).tz(...).guess is not a function #43

Open
zlayine opened this issue Jul 25, 2024 · 1 comment
Open

Nuxt 3 - dayJs(...).tz(...).guess is not a function #43

zlayine opened this issue Jul 25, 2024 · 1 comment
Labels

Comments

@zlayine
Copy link

zlayine commented Jul 25, 2024

I have an issue accessing guess with the timezone for Nuxt 3.

config:

export default defineNuxtConfig({
  modules: ['dayjs-nuxt'],
  dayjs: {
    locales: ['en'],
    plugins: ['relativeTime', 'utc', 'timezone'],
    defaultLocale: 'en',
    defaultTimezone: 'America/New_York',
  },
});

Reproduction:

https://stackblitz.com/edit/nuxt-starter-xkk6vr?file=app.vue

@tcampbPPU
Copy link
Member

thanks for the stackblitz, you might just be calling the composaible wrong, try this:

<template>
  <div>current timezone: {{ getTimezone() }}</div>
</template>

<script setup>
const dayJs = useDayjs();

const getTimezone = () => {
  return dayJs.tz.guess();
};
</script>
image

also it might not be required but if you run into issues you may need to add this dep:

  "devDependencies": {
    "dayjs": "^1.11.12",
    "dayjs-nuxt": "^2.1.9"
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants