react-datetime icon indicating copy to clipboard operation
react-datetime copied to clipboard

moment.tz is not a function | moment-timezone is installed as a dependency

Open royalidrees53 opened this issue 4 years ago • 4 comments

As per docs I have installed moment-timezone in my project but still getting moment.tz is not a function. Error occurring when I am using the prop displayTimeZone.

Project Tech: React.JS | ROR | Webpacker

royalidrees53 avatar Sep 25 '20 14:09 royalidrees53

Are you sure you are importing at least once from moment-timezone. Here's an example on how use it

https://codesandbox.io/s/happy-snowflake-gbo1b?file=/src/App.js:0-272

import * as React from "react";
import "react-datetime/css/react-datetime.css";
import Datetime from "react-datetime";
import moment from "moment-timezone";

export default function App() {
  return <Datetime displayTimeZone="America/Los_Angeles" value={new Date()} />;
}

arqex avatar Sep 27 '20 17:09 arqex

Could it be the bundler @arqex? I tried the same order as the example but it didn't work

helmerdavila avatar Oct 14 '20 21:10 helmerdavila

Hi @arqex @arqex @arqex @arqex i have also tried this but not working for me as well, i'm using Storybook for demo my standalone component with some customization but displayTimeZone is not working. any quick response would be appreciated .

moazam996 avatar Feb 22 '21 11:02 moazam996

I was having TypeError: a.a.tz is not a function error as well. Deleting and reinstalling dependencies solved it

RiinaVi avatar Dec 02 '22 10:12 RiinaVi